/// <summary> /// Disconnect from the Server and cleanup /// </summary> /// <remarks> In order to disconnect we need to dispose the ServerAgent object. /// Derived classes should always call base.InternalDisconnect from their overrides. /// </remarks> protected virtual void InternalDisconnect(ConnectionDroppedEventArgs cde) { ServerAgent serverAgentToDispose = serverAgent; if (serverAgentToDispose != null) { serverAgent = null; applicationManifest = null; // // Stop event manager. // quitHandle.Set(); eventManager.Join(1000 /* upto a second */); eventManager = null; try { // // Disconnect from server. // serverAgentToDispose.Dispose(); } catch (Exception e) { Debug.Write(e.Message); } } return; }
public void CtorSetsProperty() { string testMsg = "test msg"; ConnectionDroppedEventArgs e = new ConnectionDroppedEventArgs(new Exception(testMsg)); Assert.NotNull(e.Exception); Assert.Equal <string>(testMsg, e.Exception.Message); }
/// <summary> /// This callback will be invoked by ServerAgent when we are /// disconnected by the server due to some external reason /// </summary> /// <param name="sender">the ServerAgent raising this notification.</param> /// <param name="cde">reason for connection drop.</param> protected virtual void ConnectionDroppedHandler(object sender, ConnectionDroppedEventArgs cde) { // // Stop the event manager and cleanup if necessary. // InternalDisconnect(cde); return; }
/// <summary> /// This callback will be invoked by ServerAgent when we are /// disconnected by the server due to some external reason /// </summary> /// <param name="cde">reason for connection drop</param> protected void ConnectionDroppedHandler(object sender, ConnectionDroppedEventArgs cde) { ///stop event manager and cleanup InternalDisconnect(); ///notify all listeners who want to know that we lost ///the server connection string reason = String.Format("Reason: {0}", cde.Reason); this.DisconnectListeners(reason); return; }