Esempio n. 1
0
        public async void Join([FromBody] User userJoining, [FromQuery] string socketId)
        {
            Console.WriteLine("UserController : Join");
            if (userJoining.userId == Guid.Empty)
            {
                userJoining.userId = Guid.NewGuid();
            }

            var mess = _notificationsMessageHandler.GenerateMessageFromPayload(userJoining, MessageType.JoinRequested);
            await _notificationsMessageHandler.SendMessageAsync(socketId, mess);

            _userHandler.Add(userJoining, socketId);

            mess = _notificationsMessageHandler.GenerateMessageFromPayload(_chatHandler.GetCacheMessages(), MessageType.MessageHistory);
            await _notificationsMessageHandler.SendMessageAsync(socketId, mess);

            mess = _notificationsMessageHandler.GenerateMessageFromPayload(_userHandler.GetUsers(), MessageType.UsersRequested);
            await _notificationsMessageHandler.SendMessageAsync(socketId, mess);

            mess = _notificationsMessageHandler.GenerateMessageFromPayload(userJoining, MessageType.UserJoined);
            await _notificationsMessageHandler.SendMessageToAllAsync(mess);
        }
Esempio n. 2
0
 public async void GetList(string socketId)
 {
     Console.WriteLine("MessageController : GetList");
     var mess = _notificationsMessageHandler.GenerateMessageFromPayload(_chatHandler.GetCacheMessages(), MessageType.MessageHistory);
     await _notificationsMessageHandler.SendMessageAsync(socketId, mess);
 }