예제 #1
0
        static void FloodMessage(NetworkStream[] streams, object streamLock, Message msg)
        {
            Message floodingMsg = null;

            switch (msg.header.MSGTYPE)
            {
            case CONSTANT.CHATTING:
                floodingMsg = makeFloodingMessage(msg);     //chatting을 flooding하는 메세지를 만듦
                break;

            case CONSTANT.FLOODING:
                floodingMsg = msg;     //Do nothing.
                break;

            case CONSTANT.NOTICE:
                //아직은 NOTICE Message의 종류가 flooding 할 Message밖에 없음. 추후에 기능 추가 시 수정 요.
                floodingMsg = msg;     //Do nothing. 특정 client에게 보낼 Notice의 경우는 다른 방식으로 처리.
                break;
            }

            lock (streamLock) {
                for (int i = 0; i < 8; i++)
                {
                    if (streams[i] != null)
                    {
                        ChattingMessageUtil.Send(streams[i], floodingMsg);
                    }
                }
            }
        }
예제 #2
0
 void sendMessage(NetworkStream stream, ChattingMessage.Message msg)
 {
     try {
         ChattingMessageUtil.Send(stream, msg);
     }
     catch (SocketException) {
         stream.Close();
         client.Close();
         Application.Exit();
     }
     catch (IOException) {
         stream.Close();
         client.Close();
         Application.Exit();
     }
     catch (ObjectDisposedException) {
         appendText(tbxChattingLog, "[전송 실패: 서버와의 연결 종료됨]");
     }
 }