Beispiel #1
0
   private void onError(string message)
   {
 #if DEBUG
       var callerFrame = new StackFrame(1);
       var caller      = callerFrame.GetMethod();
       Console.WriteLine("WS: Error@{0}: {1}", caller.Name, message);
 #endif
       OnError.Emit(this, new ErrorEventArgs(message));
   }
Beispiel #2
0
 private void error(string message)
 {
     try
     {
         OnError.Emit(this, new ErrorEventArgs(message));
     }
     catch (Exception ex)
     {
     }
 }
 private void error(string message)
 {
     try {
         OnError.Emit(this, new WebSocketSharp.ErrorEventArgs(message));
         //OnError.Invoke(this, new WebSocketSharp.ErrorEventArgs (message));
     }
     catch (Exception ex) {
         Debug.LogError("An exception has occurred while OnError:\n" + ex.ToString());
     }
 }
Beispiel #4
0
 private void error(string message, Exception exception)
 {
     try
     {
         OnError.Emit(this, new ErrorEventArgs(message, exception));
     }
     catch (Exception ex)
     {
         _logger.Error(ex.ToString());
     }
 }
Beispiel #5
0
 private void error(string message, Exception exception)
 {
     try
     {
         if (exception != null)
         {
             message += ". Exception.Message: " + exception.Message;
         }
         OnError.Emit(this, new ErrorEventArgs(message));
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #6
0
        private void createWebSocket(string uri)
        {
            socket = new WebSocket(uri);
            if (Trace)
            {
                socket.Log.Level = LogLevel.Debug;
            }

            socket.OnClose += (sender, evt) =>
            {
                // Release socket handle
                socket = null;
                Logger.TraceIf(Trace, String.Format("Socket Closed. Code={0}, Reason={1}", evt.Code, evt.Reason));
                OnClose.Emit(this, new WebSocketCloseEventArgs(evt.Code, evt.Reason));
            };
            socket.OnMessage += (sender, evt) =>
            {
                if (evt.IsPing)
                {
                    Logger.TraceIf(Trace, "SocketReceive: WebSocket ping.");
                    return;
                }

                if (evt.IsText)
                {
                    Logger.TraceIf(Trace, "SocketReceive: Invalid content (text/plain).");
                    return;
                }

                OnMessage.Emit(this, new WebSocketMessageEventArgs(evt.RawData));
            };
            socket.OnError += (sender, evt) =>
            {
                if (OnError != null)
                {
                    OnError.Emit(sender, new WebSocketErrorEventArgs(evt.Exception));
                }
            };
            socket.OnOpen += (sender, evt) =>
            {
                if (OnOpen != null)
                {
                    OnOpen.Emit(sender, evt);
                }
            };
        }
Beispiel #7
0
 private void error(string message)
 {
     OnError.Emit(this, new ErrorEventArgs(message));
 }