private void chk_Chat_Allow_CheckedChanged(object sender, EventArgs e) { String ServerMsg; if (chk_Chat_Allow.Checked) { ServerMsg = "" + (char)0x02 + Convert.ToChar("OPTION : 클라이언트간 채팅을 허가.".Length * 2) + (char)0x00 + "OPTION : 클라이언트간 채팅을 허가." + (char)0x03; txt_Chat_ChatBox.Invoke(new writeLog(writeChatLog), "OPTION : 클라이언트간 채팅을 허가."); } else { ServerMsg = "" + (char)0x02 + Convert.ToChar("OPTION : 클라이언트간 채팅을 금지.".Length * 2) + (char)0x00 + "OPTION : 클라이언트간 채팅을 금지." + (char)0x03; txt_Chat_ChatBox.Invoke(new writeLog(writeChatLog), "OPTION : 클라이언트간 채팅을 금지."); } byte[] Sending_Msg = Encoding.Unicode.GetBytes(ServerMsg); // 문자열을 아스키형 바이트로 형변환 for (int index = 0; index < MaxConnectable; ++index) { try { if (ClientGroup[index] != null) { if (CLB_ConnectedList.GetItemChecked(index) != false) { ClientGroup[index].Socket.GetStream().Write(Sending_Msg, 0, Sending_Msg.Length); } } } catch { } } }
private void msg_SendAll(String msg, String Nick) { NetworkStream NS; Rtxt_Chat_Log.Invoke(new writeLog(writeChatLog), (Nick + " : " + msg)); msg = Nick + " : " + msg; msg = "" + (char)0x0002 + Convert.ToChar(msg.Length * 2) + (char)0x0000 + msg + (char)0x0003; byte[] Sending_Msg = Encoding.Unicode.GetBytes(msg); // 문자열을 아스키형 바이트로 형변환 for (int index = 0; index < MaxConnectable; ++index) { if (ClientGroup[index] != null) { if (ClientGroup[index].NickName == Nick) { continue; } try { if (ClientGroup[index] != null) { if (Nick == ServerNick && CLB_ConnectedList.GetItemChecked(index) != false) { NS = ClientGroup[index].Socket.GetStream(); Thread.Sleep(SleepTime); NS.Write(Sending_Msg, 0, Sending_Msg.Length); } else if (chk_Chat_Allow.Checked && Nick != ServerNick) { NS = ClientGroup[index].Socket.GetStream(); Thread.Sleep(SleepTime); NS.Write(Sending_Msg, 0, Sending_Msg.Length); } } } catch { } } } }