Distance Learning is a standalone application with two main components: a user interface (client/front end) and JXTA integration (back end), both of which utilize the latest JXTA platform release. The user interface displays data pertaining to communication among peers, while the JXTA integration handles the update of such data. This JXTA application is based on a simple peer-to-peer architecture. The teacher is a peer, the agent is a peer, and each student is a peer. In this program, communication between peers occurs back and forth in the following way: The teacher receives a request from the student for a question, gets a question from the agent for the student, sends that question to the student, receives an answer from the student, sends that answer to the agent, obtains the next question from the agent, and sends that question to the student. The question-answer session ends when there are no further questions. Application DetailsThe code for this application is contained in a zip file. Extract the contents of this zip file to a directory on your local disk. For your convenience, subdirectories for peers participating in this program are also available in this directory. The teacher subdirectory has a runTeacher.bat file, and each student subdirectory has a runStudent.bat file. The runTeacher.bat file launches the program, and the runStudent.bat file lets a peer join the program. Creating the Classroom with the TeacherFirst, you must create the virtual classroom with the teacher as the first peer. To create the teacher, run the runTeacher.bat program. The program launches a window for entering the configuration information about this peer. Then proceed as follows:
Upon launching the program, the teacher, peer 1, announces the teaching service and waits for students to join the class, as shown in Figure 22.1. Figure 22.1. The teacher's advertisement ready to teach.Creating a Student and Running the ProgramTo create a student as the second peer, run the runStudent.bat program in one of the student subdirectories, student01 or student02, in the installation directory. The program launches a window and prompts for information about this peer. Create this peer similarly to peer1, ensuring that this peer has a unique port number, username, and password. By creating the second peer, the application creates the community. Let's name this one peer 2. Upon launching, peer 2 (the student) forms a message requesting peer 1 (the teacher) to create a new session (examination), then sends this message to peer 1. peer 2 then waits indefinitely for an incoming message from peer 1. Upon receiving the message for a new session, the teacher creates an agent that handles the questions and answers, and also keeps track of the number of correctly answered questions. The teacher obtains the first question from the agent for the student and sends that question to the student, as shown in Figure 22.2. Figure 22.2. The teacher sends the first question.The student responds with an answer. After evaluating the student's answer, the teacher sends the next question to the student, as shown in Figure 22.3. Figure 22.3. The teacher's response after evaluating the first answer.Figure 22.4 shows how the teacher receives messages from the student and responds. Figure 22.4. The teacher's screen.When the student doesn't know the answer to a question and responds with a few question marks, the teacher provides the correct answer before sending the next question, as shown in Figure 22.5. Figure 22.5. The student doesn't know the answer to a question.The teacher and student pass questions and answers back and forth until no more questions remain. The teacher supplies the correct answer if the student's answer is incorrect. When there are no more questions, the teacher returns a suggestion based on the number of questions answered correctly. The student displays the suggestion and then exits the virtual classroom, as shown in Figure 22.6. Figure 22.6. The teacher provides additional references.Use CasesAutomation is useful in peer-to-peer communication. One of the use cases for peer-to-peer communication is automating technical support. Tech SupportIn an environment where technical support is necessary, clients needing technical help can type in a topic such as "software installation," and instead of having live people answering phone calls, the server can take over and ask a series of questions. Based on the client's answers, the server can attempt to resolve the problem or point to other resources for further information. Furthermore, the server can be versatile and base its questions on problems encountered by other clients. The server can also formulate questions based on the answers provided. In this sample program, P2P is mainly used to facilitate communication and distribute knowledge. Class DesignThe Distance Learning program uses four classes Teacher.class, AgentFactory.class, Agent.class, and Student.class to create the virtual classroom and peers, and provide an environment for communication between peers.
Special DetailsThe current implementation of the graphical user interface depends on a JAR file from the latest version of the integrated development environment called NetBeans Version 3.3. The file AbsoluteLayout.jar is required to build and/or run the Distance Learning program. |