Esempio n. 1
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            if ((textBox_Input.Text.Length > 0) && (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());
                    }
                    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 = "";
            }
        }
Esempio n. 2
0
        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 = "";
            }
        }
Esempio n. 3
0
        static void SendChatMessage(String msg)
        {
            PublicChatMsg chatMsg = new PublicChatMsg();

            chatMsg.msg = msg;

            MemoryStream outStream = chatMsg.WriteData();

            lock (clientDictionary)
            {
                foreach (KeyValuePair <String, Socket> s in clientDictionary)
                {
                    try
                    {
                        s.Value.Send(outStream.GetBuffer());
                    }
                    catch (System.Exception)
                    {
                    }
                }
            }
        }
Esempio n. 4
0
        static void SendChatMessage(String msg)
        {
            PublicChatMsg chatMsg = new PublicChatMsg();

            chatMsg.msg = msg;

            MemoryStream outStream = chatMsg.WriteData();

            lock (playerDictionary)
            {
                foreach (KeyValuePair <String, PlayerInfo> pair in playerDictionary)
                {
                    try
                    {
                        pair.Value.socket.Send(outStream.GetBuffer());
                    }
                    catch (System.Exception)
                    {
                    }
                }
            }
        }