private bool AnnounceToSession() { ServerConnectionStatusUpdateEventHandler statusChangedCallback = (s, args) => { switch (s.ConnectionStatus) { case ServerConnectionStatus.ConnectionErrorClientReconnect: case ServerConnectionStatus.Disconnected: case ServerConnectionStatus.LicenseExpired: case ServerConnectionStatus.ServerShutdown: case ServerConnectionStatus.ServerShutdownInProgress: NotConnectedCallback?.Invoke(s, args); // My idea was, to call Dispose() here, but I think, we should do it from // outside the RemoteObject context ... return; case ServerConnectionStatus.Connected: case ServerConnectionStatus.SessionAutomaticallyRecreated: PostConnectionEstablished?.Invoke(s, args); // I think, it's a good idea, to have a callback like this. So you can provide e. g. the // monitoring of some UA variables here. return; default: /* * case ServerConnectionStatus.Connecting: * case ServerConnectionStatus.ConnectionWarningWatchdogTimeout: */ return; } }; return(SessionHandle.AddStatusChangedHandler(statusChangedCallback)); }
public bool AddStatusChangedHandler(ServerConnectionStatusUpdateEventHandler statusChangedCallback) { if (StatusChangedHandler != null) { return(false); } StatusChangedHandler = statusChangedCallback; Session.ConnectionStatusUpdate += StatusChangedHandler; return(true); }