// Send a String message to the game on the server private void SendGameMessage(String message) { GameMsg GameMessage = new GameMsg(); GameMessage.msg = message; // Send to game clientList index GameMessage.destination = currentClientList[listBox_ClientList.Items.Count - 1]; MemoryStream outStream = GameMessage.WriteData(); client.Send(outStream.GetBuffer()); }
static void SendGameMessage(Socket s, String from, String msg) { GameMsg gameMessage = new GameMsg(); gameMessage.msg = msg; gameMessage.destination = from; MemoryStream outStream = gameMessage.WriteData(); try { s.Send(outStream.GetBuffer()); } catch (System.Exception) { } }
private void buttonSend_Click(object sender, EventArgs e) { if (client != null) { try { if (listBox_ClientList.SelectedIndex == 0) { PublicChatMsg publicMsg = new PublicChatMsg(); publicMsg.msg = textBox_Input.Text; MemoryStream outStream = publicMsg.WriteData(); client.Send(outStream.GetBuffer()); } // If == last item == "Game" Msg else if (listBox_ClientList.SelectedIndex == listBox_ClientList.Items.Count - 1) { GameMsg GameMessage = new GameMsg(); GameMessage.msg = textBox_Input.Text; GameMessage.destination = currentClientList[listBox_ClientList.SelectedIndex]; MemoryStream outStream = GameMessage.WriteData(); client.Send(outStream.GetBuffer()); } else { PrivateChatMsg privateMsg = new PrivateChatMsg(); privateMsg.msg = textBox_Input.Text; privateMsg.destination = currentClientList[listBox_ClientList.SelectedIndex]; MemoryStream outStream = privateMsg.WriteData(); client.Send(outStream.GetBuffer()); } } catch (System.Exception) { } textBox_Input.Text = ""; } }