/// <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(); } } }
/// <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(); } } }
protected void OnConnectionClose(bool withError) { try { ConnectionClose?.Invoke(this, withError); } catch (Exception exc) { OnError(exc, true); } }
protected void OnConnectionClose(bool withError) { System.Threading.Tasks.Task.Run(() => { ConnectionClose?.Invoke(this, withError); }).ContinueWith(task => { if (task.IsFaulted) { OnError(task.Exception.InnerException, true); } }); }
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()); } }
/// <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(); } } }
/// <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); }
public ConnectionException(ConnectionClose close):base(close.GetReplyText()) { _close = close; }
public void CloseCode(ConnectionClose close) { lock (_channels) { foreach (Channel ch in _channels.Values) { ch.CloseCode(close); } } }
public void CloseCode(ConnectionClose close) { _close = close; }
/// <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); }
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()); }
public virtual void ConnectionClose(C context, ConnectionClose mystruct) { }