コード例 #1
0
        /// <summary>
        /// Disconnect this client from the server
        /// </summary>
        /// <param name="forced">Used to tell if this disconnect was intentional <c>false</c> or caused by an exception <c>true</c></param>
        public override void Disconnect(bool forced)
        {
            if (Client == null)
            {
                return;
            }

            lock (Client)
            {
                if (forced)
                {
                    CloseConnection();
                }
                else
                {
                    var frame = new ConnectionClose(Time.Timestep, false, Receivers.Server, MessageGroupIds.DISCONNECT, false);
                    Send(frame, true);
                    Task.Queue(CloseConnection, 1000);
                }

                // Send signals to the methods registered to the disconnect events
                if (forced)
                {
                    //	OnDisconnected();
                    //else
                    OnForcedDisconnect();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Disconnect this client from the server
        /// </summary>
        /// <param name="forced">Used to tell if this disconnect was intentional <c>false</c> or caused by an exception <c>true</c></param>
        public override void Disconnect(bool forced)
        {
            Logging.BMSLog.Log("<color=cyan>FacepunchP2P client disconnecting...</color>");

            if (Lobby.Id.Value != 0)
            {
                Lobby.Leave();
            }

            if (Client == null)
            {
                return;
            }

            lock (Client)
            {
                if (forced)
                {
                    CloseConnection();
                }
                else
                {
                    var frame = new ConnectionClose(Time.Timestep, false, Receivers.Server, MessageGroupIds.DISCONNECT, false);
                    Send(frame, true);
                    Task.Queue(CloseConnection, 1000);
                }

                // Send signals to the methods registered to the disconnect events
                if (forced)
                {
                    OnForcedDisconnect();
                }
            }
        }
コード例 #3
0
ファイル: ConnectionBase.cs プロジェクト: VladimirKhil/SI
 protected void OnConnectionClose(bool withError)
 {
     try
     {
         ConnectionClose?.Invoke(this, withError);
     }
     catch (Exception exc)
     {
         OnError(exc, true);
     }
 }
コード例 #4
0
ファイル: ConnectionBase.cs プロジェクト: wurunduk/SI
 protected void OnConnectionClose(bool withError)
 {
     System.Threading.Tasks.Task.Run(() =>
     {
         ConnectionClose?.Invoke(this, withError);
     }).ContinueWith(task =>
     {
         if (task.IsFaulted)
         {
             OnError(task.Exception.InnerException, true);
         }
     });
 }
コード例 #5
0
        public override void ConnectionClose(Channel context, ConnectionClose connectionClose)
        {
            base.ConnectionClose(context, connectionClose);
            ErrorCode errorCode = ErrorCode.GetErrorCode((int)connectionClose.GetReplyCode());

            if (_client.ClosedListener != null)
            {
                _client.ClosedListener.OnClosed(errorCode, connectionClose.GetReplyText(), null);
            }

            if (errorCode.Code != (int)QpidErrorCode.NO_ERROR)
            {
                throw new Exception("Server Closed the connection: Reason " + connectionClose.GetReplyText());
            }
        }
コード例 #6
0
        /// <summary>
        /// Disconnect this client from the server
        /// </summary>
        /// <param name="forced">Used to tell if this disconnect was intentional <c>false</c> or caused by an exception <c>true</c></param>
        public override void Disconnect(bool forced)
        {
            Logging.BMSLog.Log("<color=cyan>SteamP2P client disconnecting...</color>");

            if (LobbyID.IsLobby())
            {
                SteamMatchmaking.LeaveLobby(LobbyID);
            }

            if (Client == null)
            {
                return;
            }

            lock (Client)
            {
                if (forced)
                {
                    CloseConnection();
                }
                else
                {
                    var frame =
                        new ConnectionClose(Time.Timestep, false, Receivers.Server, MessageGroupIds.DISCONNECT, false);
                    Send(frame, true);
                    Task.Queue(CloseConnection, 1000);
                }

                // Send signals to the methods registered to the disconnect events
                if (forced)
                {
                    //	OnDisconnected();
                    //else
                    OnForcedDisconnect();
                }
            }
        }
コード例 #7
0
 /// <summary>
 /// Triggered when the connection is closed from any reason.
 /// </summary>
 /// <param name="sender">IMessageClient</param>
 /// <param name="e">null</param>
 private void OnConnectionClosed(object sender, EventArgs e)
 {
     ConnectionClose?.Invoke(this, e);
 }
コード例 #8
0
		public ConnectionException(ConnectionClose close):base(close.GetReplyText())
		{
			_close = close;
		}
コード例 #9
0
ファイル: Connection.cs プロジェクト: drzo/opensim4opencog
 public void CloseCode(ConnectionClose close)
 {
     lock (_channels)
     {
         foreach (Channel ch in _channels.Values)
         {
             ch.CloseCode(close);
         }
     }
 }
コード例 #10
0
ファイル: Session.cs プロジェクト: drzo/opensim4opencog
 public void CloseCode(ConnectionClose close)
 {
     _close = close;
 }
コード例 #11
0
 /// <summary>
 /// Process this IRequest and update the given <b>Response</b> with
 /// the result.
 /// </summary>
 /// <remarks>
 /// Implementations of this method are free to throw an exception
 /// while processing the IRequest. An exception will result in the
 /// <b>Response</b> being marked as a failure that the
 /// <b>Response</b> result will be the exception itself.
 /// </remarks>
 /// <param name="response">
 /// The <b>Response</b> that will be sent back to the requestor.
 /// </param>
 /// <exception cref="Exception">
 /// If exception occurs during execution.
 /// </exception>
 protected override void OnRun(Response response)
 {
     ConnectionClose.CloseInternal(IsNotify, Cause, 0);
 }
コード例 #12
0
        public override void ConnectionClose(Channel context, ConnectionClose connectionClose)
        {
            base.ConnectionClose(context, connectionClose);
            ErrorCode errorCode = ErrorCode.GetErrorCode((int) connectionClose.GetReplyCode());

            if(_client.ClosedListener != null)
                _client.ClosedListener.OnClosed(errorCode, connectionClose.GetReplyText(), null);

            if (errorCode.Code != (int)QpidErrorCode.NO_ERROR)
                throw new Exception ("Server Closed the connection: Reason " + connectionClose.GetReplyText());
        }
コード例 #13
0
 public virtual void ConnectionClose(C context, ConnectionClose mystruct)
 {
 }