protected virtual void InternalOnDisconnected(JsonRpcDisconnectEventArgs args) { if (Logger?.IsEnabled(LogEventLevel.Debug) ?? false) { Logger.Debug("Disconnected"); } CloseStatus = args.CloseStatus; CloseStatusDescription = args.CloseStatusDescription; Error = args.Exception; if (args.Exception != null) { Socket.CloseAsync(args.CloseStatus, args.CloseStatusDescription, CancellationToken.None).GetAwaiter().GetResult(); } Socket?.Dispose(); Socket = null; Task.Factory.StartNew(a => { OnDisconnected((JsonRpcDisconnectEventArgs)a); }, args); }
protected virtual void OnDisconnected(JsonRpcDisconnectEventArgs args) { Disconnected?.Invoke(this, args); }