Exemplo n.º 1
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.");
            });
        }
Exemplo n.º 2
0
        private async Task EndpointDisconnected(IEndpoint endpoint, DisconnectedArgs args)
        {
            log.Info("endpoint disconnected (id: " + endpoint.Connection.Id + ", by " + (args.RemoteDisconnect ? "client" : "server") + ")");

            Connection connection = endpoint.Connection as Connection;

            //wait for connection to pass 'connecting' state
            using (var aLock = await connection.StateMutex.Lock(Const.DEADLOCK_TIMEOUT))
            {
                while (connection.State == ConnectionState.Connecting)
                {
                    await connection.StateMutex.Wait(aLock, Const.DEADLOCK_TIMEOUT);
                }
            }

            Data.RemoveConnection(connection);

            using (var aLock = await Mutex.Lock(Const.DEADLOCK_TIMEOUT))
            {
                _ = Messenger.BroadcastMessage(Messages.ClientDisconnected(connection));
                _ = Data.SetConnectionState(connection, ConnectionState.Disconnected);
            }

            await Modules.HandleDisconnect(connection);
        }
 private void OnDisconnected(DisconnectedArgs e)
 {
     if (Disconnected != null)
     {
         Disconnected(this, e);
     }
 }
Exemplo n.º 4
0
 private async Task ExecuteDisconnected(DisconnectedArgs args)
 {
     using (var scope = _scene.DependencyResolver.CreateChild(Constants.ApiRequestTag))
     {
         var controller = scope.Resolve <T>();
         await controller.OnDisconnected(args);
     }
 }
Exemplo n.º 5
0
        protected internal override async Task OnDisconnected(DisconnectedArgs args)
        {
            var s = sessions as UserSessions;

            if (s != null)
            {
                await s.LogOut(args.Peer);
            }
        }
Exemplo n.º 6
0
 public static EndpointChangedEventArgs Disconnect(IEndpoint endpoint, DisconnectedArgs args)
 {
     return(new EndpointChangedEventArgs()
     {
         Endpoint = endpoint,
         Type = EndpointEventType.Disconnect,
         DisconnectArgs = args
     });
 }
Exemplo n.º 7
0
        private Task OnDisconnected(DisconnectedArgs args)
        {
            long       id = args.Peer.Id;
            IScenePeer _;

            _clients.TryRemove(id, out _);
            _scene.Broadcast("di", id);
            return(Task.FromResult(true));
        }
Exemplo n.º 8
0
        public Task onDisconnected(DisconnectedArgs arg)
        {
            Player trash;

            m_players.TryRemove(arg.Peer, out trash);
            m_nbPlayer--;
            m_scene.Broadcast("PlayerDisconnected", trash);
            m_log.Debug("Connection", "Client (id : " + arg.Peer.Id + ") with player name : \"" + trash.Name + "\" disconnected from game.");
            return Task.FromResult(true);
        }
        Task onDisconnect(DisconnectedArgs args)
        {
            Player player = new Player("");

            mPlayers.TryRemove(args.Peer.Id, out player);

            mScene.Broadcast("playerLeft", player.name);

            return(Task.FromResult(true));
        }
Exemplo n.º 10
0
        public Task onDisconnected(DisconnectedArgs arg)
        {
            Player trash;
            GameInfos game;

            m_players.TryRemove(arg.Peer, out trash);
            m_log.Debug("Connection", "Client (id : " + arg.Peer.Id + ") with player name : \"" + trash.Name + "\" disconnected");
            game = m_games.Find(npc => { return (trash.ID == npc.IDOwner); });
            if (game != null)
                destroyGameLobby(game);
            return Task.FromResult(true);
        }
        internal Task PeerDisconnected(DisconnectedArgs arg)
        {
            CancellationTokenSource cts;

            if (_peersCts.TryRemove(arg.Peer.Id, out cts))
            {
                cts.Cancel();
            }



            return(Task.FromResult(true));
        }
Exemplo n.º 12
0
 void chat_Disconnected(object sender, DisconnectedArgs e)
 {
     if (IsServer)
     {
         this.Invoke(new MethodInvoker(() =>
         {
             if (this.Visible)
             {
                 Disconnect();
                 CreateServer();
             }
         }));
     }
 }
Exemplo n.º 13
0
        private Task onDisconnected(DisconnectedArgs arg)
        {
            Player temp;

            _players.TryGetValue(arg.Peer.Id, out temp);
            _scene.Broadcast("chat", temp.name + " a quitté le combat !");
            _scene.Broadcast("player_disconnected", s =>
            {
                var writer = new BinaryWriter(s, Encoding.UTF8, true);
                writer.Write(temp.id);
            }, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE_SEQUENCED);
            _players.TryRemove(temp.id, out temp);
            return(Task.FromResult(true));
        }
Exemplo n.º 14
0
        protected virtual void OnClientDisconnected(object sender, DisconnectedArgs args)
        {
            lock (clientSync)
            {
                // remove channel from our internal list
                for (int i = 0; i < _connectionList.Count; i++)
                {
                    if (_connectionList.ContainsKey(args.ClientId))
                    {
                        _connectionList.Remove(args.ClientId);
                        break;
                    }
                }

                EventHandler <DisconnectedArgs> handler = ClientDisconnected;
                if (handler != null)
                {
                    handler(this, args);
                }
            }
        }
Exemplo n.º 15
0
    Task OnDisconnected(DisconnectedArgs args)
    {
        if (_UsersInfos.ContainsKey(args.Peer.Id) == true)
        {
            ChatUserInfo temp;
            _UsersInfos.TryRemove(args.Peer.Id, out temp);

            ChatMessageDTO dto = new ChatMessageDTO();
            dto.UserInfo = temp;
            dto.Message  = args.Reason;
            foreach (IScenePeerClient clt in _scene.RemotePeers)
            {
                if (clt.Routes.Select(x => x.Name == "DiscardInfo").Any())
                {
                    clt.Send <ChatMessageDTO>("DiscardInfo", dto, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);
                }
            }
            ;
        }
        return(Task.FromResult(true));
    }
Exemplo n.º 16
0
 protected internal virtual Task OnDisconnected(DisconnectedArgs args)
 {
     return(Task.FromResult(true));
 }
Exemplo n.º 17
0
        protected virtual void OnClientDisconnected(object sender, DisconnectedArgs args)
        {
            lock (clientSync)
            {
                // remove channel from our internal list
                for (int i = 0; i < _connectionList.Count; i++)
                {
                    if (_connectionList.ContainsKey(args.ClientId))
                    {
                        _connectionList.Remove(args.ClientId);
                        break;
                    }
                }

                EventHandler<DisconnectedArgs> handler = ClientDisconnected;
                if (handler != null)
                    handler(this, args);
            }
        }
Exemplo n.º 18
0
 private Task onDisconnected(DisconnectedArgs arg)
 {
     Player temp;
     _players.TryGetValue(arg.Peer.Id, out temp);
     _scene.Broadcast("chat", temp.name + " a quitté le combat !");
     _scene.Broadcast("player_disconnected", s =>
     {
         var writer = new BinaryWriter(s, Encoding.UTF8, true);
         writer.Write(temp.id);
     }, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE_SEQUENCED);
     _players.TryRemove(temp.id, out temp);
     return Task.FromResult(true);
 }
Exemplo n.º 19
0
        private void Endpoint_Disconnected(object sender, DisconnectedArgs e)
        {
            log.Debug("endpoint disconnected " + ((IEndpoint)sender).Connection);

            ConnectionHandler.ProcessEndpoint(((IEndpoint)sender).Connection, EndpointChangedEventArgs.Disconnect((IEndpoint)sender, e)).Wait();
        }
    Task OnDisconnected(DisconnectedArgs args)
    {
        if (_UsersInfos.ContainsKey(args.Peer.Id) == true)
        {
            ChatUserInfo temp;
            _UsersInfos.TryRemove(args.Peer.Id, out temp);

            ChatMessageDTO dto = new ChatMessageDTO();
            dto.UserInfo = temp;
            dto.Message = args.Reason;
            foreach (IScenePeerClient clt in _scene.RemotePeers)
            {
                if (clt.Routes.Select(x => x.Name == "DiscardInfo").Any())
                {
                    clt.Send<ChatMessageDTO>("DiscardInfo", dto, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);
                }
            };
        }
        return Task.FromResult(true);
    }
 public Task OnClientDisconnected(DisconnectedArgs args)
 {
     _log.Debug("replicator", "player disconnected");
     foreach(IScenePeerClient client in _scene.RemotePeers)
     {
         client.Send<long>("PlayerDisconnected", args.Peer.Id, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);
     }
     return Task.FromResult(true);
 }
        private async Task OnDisconnected(DisconnectedArgs args)
        {
            var user = await _sessions.GetUser(args.Peer);

            _players[user.Id] = null;
        }
Exemplo n.º 23
0
 private void DisconnectedHandler(object socket, DisconnectedArgs e)
 {
     Disconnected?.Invoke(this, e);
 }
Exemplo n.º 24
0
 protected internal override Task OnDisconnected(DisconnectedArgs args)
 {
     pools.SetShutdown(args.Peer.SessionId);
     return(Task.CompletedTask);
 }
Exemplo n.º 25
0
 protected void SocketServerClientDisconnecting(object sender, DisconnectedArgs e)
 {
     MSMQQueueWrapper.QueueCommand(new LogoutUserCommand(e.ClientId));
 }
Exemplo n.º 26
0
 private Task OnDisconnected(DisconnectedArgs args)
 {
     long id = args.Peer.Id;
     IScenePeer _;
     _clients.TryRemove(id, out _);
     _scene.Broadcast("di", id);
     return Task.FromResult(true);
 }
Exemplo n.º 27
0
        /// <summary>
        /// Called when the client disconnects from the server normally (before <see cref="OnDisconnectedAsync(Exception)"/>).
        ///
        /// Used to pass any data needed for normal disconnection.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public async Task Disconnected(DisconnectedArgs args)
        {
        }
Exemplo n.º 28
0
 private async Task OnDisconnected(DisconnectedArgs arg)
 {
     Player player;
     if (_players.TryRemove(arg.Peer.Id, out player))
     {
         Ship ship;
         if (_ships.TryRemove(player.ShipId, out ship))
         {
             List<long> _;
             _boidsTimes.TryRemove(player.ShipId, out _);
             _scene.GetComponent<ILogger>().Info("gameScene", "removed ship");
             _scene.Broadcast("ship.remove", ship.id, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);
         }
     }
 }
Exemplo n.º 29
0
 protected void OnDisconnected(object o, DisconnectedArgs args)
 {
     EnableMainMenu(false);
     LogInfo("Disconnected\n");
 }
Exemplo n.º 30
0
 static void client_ClientClosed(object sender, DisconnectedArgs e)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 31
0
 protected void SocketServerClientDisconnecting(object sender, DisconnectedArgs e)
 {
     MSMQQueueWrapper.QueueCommand(new LogoutUserCommand(e.ClientId));
 }
Exemplo n.º 32
0
 private void _socket_Disconnected(object sender, DisconnectedArgs e)
 {
     Disconnected?.Invoke(this, e);
 }
Exemplo n.º 33
0
 //onDiconnected is called by the disconnected event
 //it can be used to remove client data stored on the scene such as nicknames, score, etc...
 //
 private Task OnDisconnect(DisconnectedArgs arg)
 {
     _playersConnected--;
     _log.Debug("main", arg.Peer.Id.ToString() + " has disconnected (" + arg.Reason + ")");
     return Task.FromResult(true);
 }