Example #1
0
        public async void OnUserJoined(User user, Meeting meeting)
        {
            var sendTasks = _sockets.Where(s => IsUserInMeeting(s.UserId, meeting.Id))
                            .Select(s => s.SendObjectAsync(UserJoinedEvent.FromUser(user)));

            await Task.WhenAll(sendTasks);
        }
Example #2
0
        public void Handle(UserJoinedEvent args)
        {
            Logger.LogInformation($"SIGNALR - {UserJoined} - {args.User.Name} has joined the chat.");
            var result = new UsersDto()
            {
                User  = Mapper.Map <User, UserDto>(args.User),
                Users = Mapper.Map <IEnumerable <User>, IEnumerable <UserDto> >(args.Users)
            };

            _connectionManager.Clients.All.SendAsync(UserJoined, JsonConvert.SerializeObject(result));
        }
Example #3
0
        public UserJoinedEventHandlerForReadStoreTestsFixture()
        {
            ReadStoreMediator     = new Mock <IReadStoreMediator>();
            MessageHandlerContext = new Mock <IMessageHandlerContext>();
            MessageHandlerContext.Setup(x => x.MessageId).Returns(MessageId);

            Message = new UserJoinedEvent {
                AccountId = AccountId,
                UserRef   = UserRef,
                Role      = Role,
                Created   = Created
            };

            Handler = new UserJoinedEventHandler(ReadStoreMediator.Object);
        }
Example #4
0
 private void ChatClient_OnUserJoined(object sender, UserJoinedEvent e)
 => OnUserJoined?.Invoke(e);
Example #5
0
 protected virtual void OnUserJoined(RemoteServer server, ChannelUserEventArgs args)
 {
     UserJoinedEvent?.Invoke(server, args);
 }
Example #6
0
        private async Task CompositeChatClient_OnUserJoined(UserJoinedEvent e)
        {
            await chatterRepository.UpsertChatter(e.Username, datetimeProvider.UtcNow).ConfigureAwait(false);

            await ruleCheckService.CheckRulesForUserInChannel(e.Username, e.Channel).ConfigureAwait(false);
        }
Example #7
0
        public void OnChatPacket(PacketReader reader)
        {
            int messageNum = reader.ReadInt16();

            reader.ReadString(4);   // Language

            byte[] packet = reader.GetData();

            switch (messageNum)
            {
            case 0x25:
            {
                int    messageType = reader.ReadInt16();
                string username    = reader.ReadUnicodeString();
                string message     = reader.ReadUnicodeString();

                Match matches = Regex.Match(message, "{(.*)}\\s+(.*)");

                if (matches.Success)
                {
                    string channel = matches.Groups[1].Value;
                    string text    = matches.Groups[2].Value;

                    Messages.Add(new ChatMessage {
                            Username = username, Channel = channel, Text = text
                        });
                    ChatMessageEvent?.Invoke(username, channel, text);
                }

                break;
            }

            case 0x3e8:
            {
                string channel = reader.ReadUnicodeString();

                if (!Channels.Contains(channel))
                {
                    Channels.Add(channel);
                    ChannelCreatedEvent?.Invoke(channel);
                }

                break;
            }

            case 0x3e9:
            {
                string channel = reader.ReadUnicodeString();

                if (Channels.Contains(channel))
                {
                    Channels.Remove(channel);
                    ChannelRemovedEvent?.Invoke(channel);
                }

                break;
            }

            case 0x3ee:
            {
                reader.ReadInt16();
                string userName = reader.ReadUnicodeString();

                if (!Users.Contains(userName))
                {
                    Users.Add(userName);
                    UserJoinedEvent?.Invoke(userName, string.Empty);
                }

                break;
            }

            case 0x3ef:
            {
                string userName = reader.ReadUnicodeString();

                if (Users.Contains(userName))
                {
                    Users.Remove(userName);
                    UserLeftEvent?.Invoke(userName, string.Empty);
                }

                break;
            }

            case 0x3f1:
            {
                CurrentChannel = reader.ReadUnicodeString();
                JoinedChatChannelEvent?.Invoke(CurrentChannel);
                break;
            }

            case 0x3f0:
            {
                Users.Clear();
                ClearUsersEvent?.Invoke();
                break;
            }

            case 0x3f4:
            {
                LeftChatChannelEvent?.Invoke(CurrentChannel);
                CurrentChannel = null;
                break;
            }

            // ReSharper disable once RedundantEmptySwitchSection
            default:
                break;
            }
        }