/// <summary> /// Called by the unmanaged socket server if a peer disconnects (or is disconnected). /// </summary> /// <param name="photonPeer">The peer which disconnected.</param> /// <param name="userData"> The user data.</param> /// <param name="reasonCode">The disconnect reason code.</param> /// <param name="reasonDetail">The disconnect reason detail.</param> /// <param name="rtt">The round trip time.</param> /// <param name="rttVariance">The round trip time variance.</param> /// <param name="numFailures"> The amount of failures. </param> void IPhotonApplication.OnDisconnect(IPhotonPeer photonPeer, object userData, DisconnectReason reasonCode, string reasonDetail, int rtt, int rttVariance, int numFailures) { try { IManagedPeer peer = userData as IManagedPeer; if (peer != null) { if (log.IsDebugEnabled) { log.DebugFormat("OnDisconnect - ConnID={0}", new object[] { photonPeer.GetConnectionID() }); } if (peer.Application_OnDisconnect(reasonCode, reasonDetail, rtt, rttVariance, numFailures)) { this.DecrementPeerCounter(); } } else if (log.IsDebugEnabled) { log.DebugFormat("OnDisconnect - Peer not found: {0}", new object[] { photonPeer.GetConnectionID() }); } } catch (Exception exception) { log.Error(exception); throw; } finally { photonPeer.SetUserData(null); } }
/// <summary> /// Callback for failed outbound connections. /// </summary> /// <param name="photonPeer"> The photon peer.</param> /// <param name="userData">The user data.</param> /// <param name="errorCode">The error Code.</param> /// <param name="errorMessage">The error message</param> void IPhotonApplication.OnOutboundConnectionFailed(IPhotonPeer photonPeer, object userData, int errorCode, string errorMessage) { try { TemporaryServerPeer peer = userData as TemporaryServerPeer; if (peer != null) { this.OnServerConnectionFailed(errorCode, errorMessage, peer.State); } else { log.ErrorFormat("Outbound connection failed for peer {0}: {1} - {2}; user data contained unexpected data: {3}", new object[] { photonPeer.GetConnectionID(), errorCode, errorMessage, userData }); } } catch (Exception exception) { log.Error(exception); throw; } finally { photonPeer.SetUserData(null); } }