Example #1
0
        public Task OnDisconnected(ChatDisconnectedContext ctx)
        {
            DateTimeOffset _;

            _jail.TryRemove(ctx.UserId, out _);
            return(Task.CompletedTask);
        }
Example #2
0
        private async Task OnDisconnected(DisconnectedArgs args)
        {
            ChatUserInfoDto disconnectingInfo = null;

            _connectedUsers.TryRemove(args.Peer, out disconnectingInfo);

            if (disconnectingInfo == null)
            {
                throw new InvalidOperationException("Client doesn't connected.");
            }

            disconnectingInfo.Status = UserStatusDto.Disconnected;

            _scene.Broadcast("statuschange", (s) => {
                args.Peer.Serializer().Serialize((int)UserStatusDto.Disconnected, s);
                args.Peer.Serializer().Serialize(disconnectingInfo, s);
            });

            ChatDisconnectedContext chatDisconnected = new ChatDisconnectedContext(disconnectingInfo.UserId);
            await _chatEventHandler?.RunEventHandler(eh =>
            {
                return(eh.OnDisconnected(chatDisconnected));
            }, ex =>
            {
                _log.Log(LogLevel.Error, _logCategory, "An error occured when the chat service try to dispose observable.", ex);
                throw new ClientException($"An error occured when the chat service try to dispose observable.");
            });
        }