Ejemplo n.º 1
0
 private void HandleUserChanged(User u)
 {
     if (u.Username == _appGlobal.Username)
         return;
     if (InvokeRequired)
     {
         Invoke(new Action(() => HandleUserChanged(u)));
         return;
     }
     RemoveUsersFromcmbBox();
     LoadUsers(_appGlobal.Users.Where(x => x.Username != _appGlobal.Username).ToList());
 }
Ejemplo n.º 2
0
 private void OnUserChangedEvent(User u)
 {
     UserDelegate handler = UserChangedEvent;
     if (handler != null) handler(u);
 }
Ejemplo n.º 3
0
 private void PacketReceived(Packet p)
 {
     Console.WriteLine(p.ToJsonObject().ToString());
     if (p is SerialDataPushPacket)
     {
         Console.WriteLine("push packet received!");
         OnIncomingMeasurementEvent(p as SerialDataPushPacket);
     }
     else if (p is UserChangedPacket)
     {
         var packet = p as UserChangedPacket;
         if (packet.Username == this.Username)
             return;
         User x = Users.FirstOrDefault(u => u.Username == packet.Username);
         if (x == null)
         {
             x = new User(packet.Nickname, packet.Username, null);
             Users.Add(x);
         }
         x.OnlineStatus = packet.Status;
         OnUserChangedEvent(x);
     }
     else if (p is LoginResponsePacket)
     {
         OnLoginResultEvent(p as LoginResponsePacket);
     }
     //else if (p is RegisterResponsePacket)
     //{
     //    var packet = p as RegisterResponsePacket;
     //    OnRegisterResultEvent(packet.Status);
     //}
     //else if (p is PullResponsePacket<ChatMessage>)
     //{
     //    var packet = p as PullResponsePacket<ChatMessage>;
     //    FillChatMessageList(packet.Data.ToList());
     //    Console.WriteLine("PullResponsePacket<ChatMessage> received!");
     //}
     //else if (p is PullResponsePacket<User>)
     //{
     //    var packet = p as PullResponsePacket<User>;
     //    foreach (User u in packet.Data.ToList())
     //    {
     //        Users.Add(u);
     //    }
     //    InitializeContacts();
     //}
     else if (p is ResponsePacket) //this one should be last!
     {
         OnResultEvent(p as ResponsePacket);
     }
 }
 public UserChangedPacket(User user) : base(DefCmd)
 {
     Initialize(user.Username, user.Nickname, user.OnlineStatus);
 }
Ejemplo n.º 5
0
 public bool AddUser(User user)
 {
     _users.Add(user);
     return true;
 }