In C++ Build a personal weekly schedule manager In this programming assignment,
ID: 3864061 • Letter: I
Question
In C++ Build a personal weekly schedule manager
In this programming assignment, you are going to build a simple on-line personal weekly schedule manager.
You need to implement the protocol, and write a client and a server that communicate using your protocol through TCP sockets. Your scheduler server should be a concurrent application server that handles different scheduler clients at the same time. Your scheduler protocol should be able to allow the following functionalities:
• Add a user
• Delete a user
• Modify user information: Name, password, contact phone number, and email address
• User login authentication with user name and password
• Add a new appointment
• Remove an appointment
• Update an existing appointment
• Check a user’s appointment time conflict
• Display a user’s the appointment for a specific time or a time range
• Proper exception handling
• NOTE: Assume your calendar server does not allow multiple logins with same
user id (user name) at simultaneously.
• All connections between a server and clients should be TCP/IP socket.
• A server and client should run on different machines.
Explanation / Answer
using System.Net.Sockets; using RedCorona.Net; class SimpleClient{ ClientInfo client; void Start(){ Socket sock = Sockets.CreateTCPSocket("www.myserver.com", 2345); client = new ClientInfo(sock, false); // Don't start receiving yet client.OnReadBytes += new ConnectionReadBytes(ReadData); client.BeginReceive(); } void ReadData(ClientInfo ci, byte[] data, int len){ Console.WriteLine("Received "+len+" bytes: "+ System.Text.Encoding.UTF8.GetString(data, 0, len)); } void Start(){ Socket sock = Sockets.CreateTCPSocket("www.myserver.com", 2345); client = new ClientInfo(sock, false); // Don't start receiving yet client.OnRead += new ConnectionRead(ReadData); client.Delimiter = ' '; // this is the default, shown for illustration client.BeginReceive(); } void ReadData(ClientInfo ci, String text){ Console.WriteLine("Received text message: "+text); switch(code){ case 0: Console.WriteLine("A message: "+ System.Text.Encoding.UTF8.GetString(bytes, 0, len)); break; case 1: Console.WriteLine("An error: "+ System.Text.Encoding.UTF8.GetString(bytes, 0, len)); break; bool ClientConnect(Server serv, ClientInfo new_client){ new_client.Delimiter = ' '; new_client.OnRead += new ConnectionRead(ReadData); return true; // allow this connection } void ReadData(ClientInfo ci, String text){ Console.WriteLine("Received from "+ci.ID+": "+text); if(text[0] == '!') server.Broadcast(Encoding.UTF8.GetBytes(text)); else ci.Send(text); } }