Пример #1
0
        private void OnSocketError(string message, SocketError se)
        {
            NetWorkEvent bitSwarmEvent = new NetWorkEvent(NetWorkEvent.IO_ERROR);

            bitSwarmEvent.Params            = new Dictionary <string, object>();
            bitSwarmEvent.Params["message"] = message + " ==> " + se;
            DispatchEvent(bitSwarmEvent);
        }
Пример #2
0
        private void OnSocketConnect()
        {
            attemptingReconnection = false;
            NetWorkEvent networkEvent = new NetWorkEvent(NetWorkEvent.CONNECT);
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary["success"]        = true;
            dictionary["isReconnection"] = attemptingReconnection;
            networkEvent.Params          = dictionary;
            DispatchEvent(networkEvent);
        }
Пример #3
0
 private void OnSocketData(ByteBuffer data)
 {
     try
     {
         ioHandler.OnDataRead(data);
     }
     catch (Exception ex)
     {
         NetWorkEvent bitSwarmEvent             = new NetWorkEvent(NetWorkEvent.DATA_ERROR);
         Dictionary <string, object> dictionary = new Dictionary <string, object>();
         dictionary["message"] = ex.ToString();
         bitSwarmEvent.Params  = dictionary;
         DispatchEvent(bitSwarmEvent);
     }
 }
Пример #4
0
        private void OnSocketConnectFailure()
        {
            if (!attemptingReconnection)
            {
                firstReconnAttempt = DateTime.Now;
            }
            attemptingReconnection = true;

            NetWorkEvent networkEvent = new NetWorkEvent(NetWorkEvent.CONNECTFAILURE);
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary["success"]        = false;
            dictionary["isReconnection"] = attemptingReconnection;
            networkEvent.Params          = dictionary;
            DispatchEvent(networkEvent);

            Reconnect();
        }
Пример #5
0
 private void DispatchEvent(NetWorkEvent evt)
 {
     dispatcher.DispatchEvent(evt);
 }