Beispiel #1
0
        public override void OnOpen()
        {
            if (DBSupport.GetUser(user) == null)
            {
                DBSupport.AddNewUser(user);
            }

            SocketMessage socMsg = new SocketMessage()
            {
                Type       = SocketMessage.MessageType.JoinedPub,
                Packetizer = new SocketMessage.DataGram
                {
                    User       = user,
                    UsersCount = DBSupport.GetUsersCount()
                }
            };

            chatClients.BroadcastExcept(chatClients, this.user, JsonConvert.SerializeObject(socMsg));

            socMsg = new SocketMessage()
            {
                Type       = SocketMessage.MessageType.JoinedPvt,
                Packetizer = new SocketMessage.DataGram
                {
                    User       = null,
                    Users      = DBSupport.GetAllUsers(),
                    UsersCount = DBSupport.GetUsersCount()
                }
            };
            this.Send(JsonConvert.SerializeObject(socMsg));
            chatClients.Add(this);
        }
Beispiel #2
0
 public void NewUserJoining(ChatUser user)
 {
     if (DBSupport.IsIdExist(user.Id))
     {
         DBSupport.UpdateUser(user);
     }
     else
     {
         DBSupport.AddNewUser(user);
     }
     Clients.Others.newUserJoined(user);
     Clients.Caller.youJoined(DBSupport.GetAllUsers());
     Clients.All.totalUsers(DBSupport.GetUsersCount());
 }