void m_TerminalClient_Connected(Socket socket) { SimpleMessage message = new SimpleMessage("Hello There"); int messageKing = (int)MessageKind.Simple; byte[] buffer = MessageComposer.Serialize(messageKing, message); m_ClientTerminal.SendMessage(buffer); cmdConnect.Enabled = false; cmdClose.Enabled = true; PresentMessage(listLog, "Connection Opened!"); m_ClientTerminal.StartListen(); PresentMessage(listLog, "Start listening to server messages"); }
private void cmdSendMessage_Click(object sender, EventArgs e) { try { string mes = txtData.Text; // Create the concrete message SendingTimeMessage message = new SendingTimeMessage(mes); int messageKind = (int)MessageKind.SendingTime; byte[] buffer = MessageComposer.Serialize(messageKind, message); // Send the message (as bytes) to the server. m_ClientTerminal.SendMessage(buffer); } catch (SocketException se) { MessageBox.Show(se.Message); } }