/// <summary> /// Open Document Dialog Box /// </summary> public DocNameDialog(NetworkWarden ward) { InitializeComponent(); warden = ward; OpenInput1.Focus(); }
/// <summary> /// Callback function upon successful connection attempt /// </summary> /// <param name="warden"></param> private void Connected(NetworkWarden ward) { if (ward != null) { warden = ward; } }
/// <summary> /// Constructor used for Multi-user Spreadsheet /// </summary> public SSForm(NetworkWarden ward, string filename) { InitializeComponent(); istyping = false; oldAddress = "A1"; personalSpreadsheet = new Spreadsheet(validAddress, s => s.ToUpper(), "PS6"); this.Text = filename; addressBox.Text = "A1"; warden = ward; warden.callNext = Sent_Message; // Set warden callback function for server messages listenWarden = new NetworkWarden(warden.socket, warden.ID); listenWarden.callNext = Receive_Message; // Send the filename to the server Networking.getData(listenWarden); System.Threading.Thread.Sleep(800); try { Networking.Send(warden, "Connect\t" + filename + "\t\n"); } catch (Exception err) { while (MessageBox.Show("Server is down, application will now close.", "", MessageBoxButtons.OK) == 0) { } Application.Exit(); } }
/******************************************************************************************** * Network Comunication Section - Server -> Client ********************************************************************************************/ /// <summary> /// Receive hub - decodes message and activate proper command /// </summary> public void Receive_Message(NetworkWarden ward) { if (ward.buffString == null) { return; } string msg = ward.buffString; Array.Clear(ward.buffer, 0, ward.buffer.Length); ward.buffString = ""; ward.message.Clear(); string[] parsedMsg = msg.Split('\t'); switch (parsedMsg[0]) { case "Change": this.Invoke(new MethodInvoker(() => Receive_Change(parsedMsg))); break; case "IsTyping": this.Invoke(new MethodInvoker(() => Receive_IsTyping(parsedMsg))); break; case "DoneTyping": this.Invoke(new MethodInvoker(() => Receive_DoneTyping(parsedMsg))); break; default: // error in Received message: gracefully close everything System.Diagnostics.Debug.Print("Bad Message Recieved"); break; } Networking.getData(ward); }
public SSForm(NetworkWarden ward, string filename) { InitializeComponent(); personalSpreadsheet = new Spreadsheet(validAddress, s => s.ToUpper(), "PS6"); this.Text = filename; warden = ward; addressBox.Text = "A1"; // Send the filename to the server Networking.Send(warden, "Connect\t" + filename + "\t\n"); }
/// <summary> /// Callback function upon successful connection attempt /// </summary> /// <param name="warden"></param> private void Connected(NetworkWarden ward) { if (ward != null) { validServer = true; warden = ward; } else { validServer = false; } }
/// <summary> /// Use to send messages to the server /// </summary> /// <param name="ward"></param> private void Sent_Message(NetworkWarden ward) { if (ward.buffString == null) { return; } string msg = ward.buffString; ward.buffString = null; string[] parsedMsg = msg.Split('\t'); started = true; this.Invoke(new MethodInvoker(() => Receive_Startup(parsedMsg))); }