Example #1
0
        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);
        }
Example #2
0
 protected virtual void OnDisconnected(JsonRpcDisconnectEventArgs args)
 {
     Disconnected?.Invoke(this, args);
 }