示例#1
0
        public void AddClient(TcpClient socket, object token, string userName)
        {
            ClientHandler client = new ClientHandler(socket, token, userName, DisconnectClient);

            _clientList.Add(client);

            drawText.DrawTex(string.Format("[System] {0} join the room {1}", client.Id, roomName));
            SendClientAll(string.Format("[System] {0} 님이 {1} 방에 입장하였습니다.",
                                        client.Id, roomName));

            AddTesk(client);
        }
示例#2
0
        public void NewCreateClient(TcpClient socket, object token)
        {
            try
            {
                // 클라이언트에서 버퍼를 읽어옴
                NetworkStream stream    = socket.GetStream();
                byte[]        buff      = new byte[BufferSize];
                int           nBuffSize = stream.Read(buff, 0, buff.Length);

                // 유니코드 변환 & 문자열 자르기
                string userName = Encoding.Unicode.GetString(buff, 0, nBuffSize);
                userName = userName.Substring(0, userName.Length);


                NetWorkRoom room;
                _roomDictionary.TryGetValue("Lobby", out room);
                room.AddClient(socket, token, userName);
            }
            catch (Exception e)
            {
                _texBox.DrawTex(e.Message);
            }
        }