Esempio n. 1
0
 private void btnSend_Click(object sender, EventArgs e)
 {
     try
     {
         ServerEvent serverEvent = new ServerEvent();
         serverEvent.SendServerLog(tbxSendData.Text);
         SendMessageAll(tbxSendData.Text, "Server", false);
         DisplayText("Server >" + tbxSendData.Text);
         tbxSendData.Text = "";
     }
     catch (Exception ex) { }
 }
Esempio n. 2
0
 private void btnSend_Click(object sender, EventArgs e)
 {
     try
     {
         ServerEvent.SendServerLog(tbxSendData.Text);
         SendMessageAll("Server/" + tbxSendData.Text, cbxChannel.Text, true);
         DisplayText("Server /" + cbxChannel.Text + ">" + tbxSendData.Text);
         tbxSendData.Text = "";
     }
     catch (Exception ex)
     {
         ServerEvent.ErrorLog("btnStart_Click", ex.Message);
     }
 }
Esempio n. 3
0
        public void SendMessageAll(string message, string channel, bool isServer)
        {
            try
            {
                foreach (var pair in ClientList)
                {
                    TcpClient client = pair.Key as TcpClient;
                    IpPoint = (IPEndPoint)client.Client.RemoteEndPoint;
                    NetworkStream stream = client.GetStream();
                    byte[]        buffer = null;

                    // 20200820 서버 전용 암호화 기능 추가
                    if (isServer)
                    {
                        string sendmessage = Encrypted.EncryptedMessage(message, IpPoint.Address.ToString());
                        ServerEvent.SendServerLog(sendmessage);
                        if (channel == pair.Value)
                        {
                            buffer = Encoding.Unicode.GetBytes("ⓐ" + sendmessage);
                            stream.Write(buffer, 0, buffer.Length);
                            stream.Flush();
                        }
                        else if (channel == "All")
                        {
                            buffer = Encoding.Unicode.GetBytes("ⓐ" + sendmessage);
                            stream.Write(buffer, 0, buffer.Length);
                            stream.Flush();
                        }
                    }
                    else
                    {
                        if (channel == pair.Value)
                        {
                            buffer = Encoding.Unicode.GetBytes(message);
                            stream.Write(buffer, 0, buffer.Length);
                            stream.Flush();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ServerEvent.ErrorLog("SendMessageAll", ex.Message);
            }
        }