The Distance Learning program illustrates the usage of JXTA community formation, discovery procedures, and peer-to-peer communication protocols. In this program, the teacher is the server and the student is the client. There can be more than one client, but the current sample shows only one client. Upon launching, the teacher/server sets up a JXTA environment and remotely publishes a JXTA pipe advertisement, announcing the teaching service. The server then creates an input pipe using that advertisement, and waits for the student/client to connect. Upon launching, the client sets up a JXTA environment, automatically connects to the server, and searches for the server's pipe advertisement. Once it discovers the pipe advertisement using JXTA discovery service, it creates an output pipe using that advertisement to send messages to the server. Subsequently, it creates a JXTA pipe to advertise its own presence, and an input pipe for inbound messages from the server. Upon receiving the message for a new session from the client, the server creates an agent through an agent factory. The agent handles the session of questions and answers, and keeps track of the number of correctly answered questions. The server obtains questions from the agent, sends the questions to the client, receives answers from the client, and sends the answers to the agent. This communication occurs in a cycle. That is, the server sends the first question to the client and subsequently sends a question after receiving an answer for the previous question. At the end of the session, upon receiving suggestions from the server for further research, the client exits the program. |