Ejemplo n.º 1
0
        public void ConnectionCreated(ConnectionClient connection)
        {
            if (Connection != null)
            {
                Disconnect(EDisconnectReason.ClientJoinedAnotherServer);
            }

            Connection = connection;
            OnConnectionCreated?.Invoke(Connection);
            Connection.Connect();

            Logger.Debug("Connection to server created {connection}", Connection);
        }
Ejemplo n.º 2
0
        public void Disconnect(EDisconnectReason eReason)
        {
            if (Connection == null)
            {
                throw new InvalidStateException("Client is not connected. Cannot disconnect.");
            }

            Connection.Disconnect(eReason);
            Logger.Debug(
                "Disconnect from server {connection}. Reason: {reason}.",
                Connection,
                eReason);
            Connection = null;
            OnConnectionDestroyed?.Invoke(eReason);
        }