コード例 #1
0
ファイル: ChatServer.cs プロジェクト: Greeley/Samples
        /// <summary>
        /// Create a new client
        /// </summary>
        /// <param name="remoteEndPoint">IP address of the remote end point</param>
        /// <returns>
        /// Created client
        /// </returns>
        public IServerService CreateClient(EndPoint remoteEndPoint)
        {
            var client = new ClientChatConnection(this);
            client.Disconnected += OnClientDisconnect;

            lock (_connectedClients)
                _connectedClients.Add(client);

            return client;
        }
コード例 #2
0
ファイル: ChatServer.cs プロジェクト: Greeley/Samples
        /// <summary>
        /// Send message to all connected clients but me
        /// </summary>
        /// <param name="me"></param>
        /// <param name="message"></param>
        public void SendToAllButMe(ClientChatConnection me, ChatMessage message)
        {
            lock (_connectedClients)
            {
                foreach (var client in _connectedClients)
                {
                    if (client == me)
                        continue;

                    client.Send(message);
                }
            }
        }