コード例 #1
0
ファイル: ChatService.cs プロジェクト: ChaosCom/scs
        public void Login(UserInfo info)
        {
            if (FindClientByNick(info.Nick) != null)
            {
                throw new NicknameInUseException(String.Format("Nickname {0} already in use."));
            }
            var client = CurrentClient;
            client.Disconnected += client_Disconnected;

            var proxy =  client.GetClientProxy<IChatClient>();
            var chatClient = new ChatClient(client, proxy, info);

            _clients[client.ClientId] = chatClient;

            Task.Factory.StartNew(
                () => {
                    OnUserListChanged();
                    SendUserListToClient(chatClient);
                    SendNewUserInfoToAllClients(info);
                }
            );
        }
コード例 #2
0
ファイル: ChatService.cs プロジェクト: ChaosCom/scs
 private void SendUserListToClient(ChatClient client)
 {
     //send the list of Users to a newly joined client, minus its own nick
     var userArray = UserList.Where((user) => user.Nick != client.User.Nick).ToArray();
     if (userArray.Length <= 0) return;
     client.ClientProxy.GetUserList(userArray);
 }