Beispiel #1
0
 static void _scsClient_Connected(object sender, EventArgs e)
 {
     Console.WriteLine("Client connected");
     Random r  = new Random();
     currentUser = new UserInfo { Nick = r.Next().ToString() };
     scs.ServiceProxy.Login(currentUser);
 }
Beispiel #2
0
 public void OnUserLogin(UserInfo info)
 {
     Console.WriteLine("OnUserLogin: {0}", info.Nick);
 }
Beispiel #3
0
 public void GetUserList(UserInfo[] users)
 {
 }
Beispiel #4
0
        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);
                }
            );
        }
Beispiel #5
0
        private void SendNewUserInfoToAllClients(UserInfo info)
        {
            var clients = _clients.GetAllItems();

            foreach (var client in clients)
            {
                if (client.User.Nick == info.Nick) continue;
                try
                {
                    client.ClientProxy.OnUserLogin(info);
                } catch (Exception)
                {

                }
            }
        }
Beispiel #6
0
 public ChatClient(IScsServiceClient client, IChatClient clientProxy, UserInfo userInfo)
 {
     Client = client;
     ClientProxy = clientProxy;
     User = userInfo;
 }