Exemple #1
0
 private void OnUserUpdate(ChatUserInfo info)
 {
     _users.AddOrUpdate(info.ClientId, info, (_, old) =>
     {
         old.User = info.User;
         return(old);
     });
 }
Exemple #2
0
        Task OnMessageReceived(Packet <IScenePeerClient> packet)
        {
            var          dto = new ChatMessageDTO();
            ChatUserInfo temp;

            if (_UsersInfos.TryGetValue(packet.Connection.Id, out temp) == false)
            {
                temp          = new ChatUserInfo();
                temp.ClientId = packet.Connection.Id;
                temp.User     = "";
            }
            dto.UserInfo  = temp;
            dto.Message   = packet.ReadObject <string>();
            dto.TimeStamp = _env.Clock;

            AddMessageToCache(dto);

            _scene.Broadcast("chat", dto, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);

            return(Task.FromResult(true));
        }