Exemplo n.º 1
0
        private void ConnectThread(object obj)
        {
            object exception_LOCK = this.EXCEPTION_LOCK;

            lock (exception_LOCK)
            {
                this.mException = null;
            }
            List <object>            list   = (List <object>)obj;
            Action <bool, Exception> action = (Action <bool, Exception>)list[0];

            try
            {
                if (this.Connect(this.mTimeOut, list[1]))
                {
                    action(true, null);
                }
                else
                {
                    action(false, null);
                }
            }
            catch (NpCloudException arg)
            {
                action(false, arg);
            }
            catch (Exception arg2)
            {
                action(false, arg2);
            }
        }
Exemplo n.º 2
0
 protected override void SocketThread()
 {
     while (this.IsConnected)
     {
         if (Environment.TickCount < this.mPongTime + base.PongIntervalTime)
         {
             return;
         }
         object obj = this.mSocket;
         lock (obj)
         {
             if (!this.mSocket.Ping())
             {
                 this.mPongCount++;
             }
         }
         this.mPongTime = Environment.TickCount;
         if (base.PongEndCount < this.mPongCount)
         {
             NpCloudException e = new NpCloudException(750, "Pongにより切断された");
             base.ReceiveException(e);
             this.mIsError = false;
         }
         Thread.Sleep(50);
     }
 }
Exemplo n.º 3
0
 protected override void SocketThread()
 {
     try
     {
         this.mReceivebuffer = new byte[1024];
         if (this.mReceponseStream != null)
         {
             this.mReceponseStream.Dispose();
         }
         this.mReceponseStream = new MemoryStream();
         this.mWritePoint      = 0L;
         this.mReadPoint       = 0L;
         this.mReceponseSize   = 0u;
         this.mHeaderBuffer    = new byte[10];
         this.mReceponseType   = 0;
         this.mIsReceponse     = false;
         byte[] tmpBuffer = null;
         while (this.mIsReceiveThread)
         {
             object obj = this.mLockObject;
             lock (obj)
             {
                 if (this.mSocket.Poll(0, SelectMode.SelectWrite))
                 {
                     this.PingPong();
                     this.SendLoop(tmpBuffer);
                 }
                 this.Receive();
             }
             while (this.mIsReceiveThread)
             {
                 if (this.Receponse())
                 {
                     break;
                 }
             }
             Thread.Sleep(50);
         }
     }
     catch (NpCloudException e)
     {
         base.ReceiveException(e);
     }
     catch (SocketException ex)
     {
         short            exitCode = 752;
         string           message  = string.Format("Message = {0}\nStackTrace = {1}", ex.Message, ex.StackTrace);
         NpCloudException e2       = new NpCloudException(exitCode, message);
         base.ReceiveException(e2);
     }
     catch (Exception ex2)
     {
         short            exitCode2 = 753;
         NpCloudException e3        = new NpCloudException(exitCode2, ex2.Message);
         base.ReceiveException(e3);
     }
 }
Exemplo n.º 4
0
        protected void ReceiveException(NpCloudException e)
        {
            object exception_LOCK = this.EXCEPTION_LOCK;

            lock (exception_LOCK)
            {
                this.mException = null;
                this.mException = e;
            }
        }
Exemplo n.º 5
0
 private void PingPong()
 {
     if (Environment.TickCount < this.mPongTime + base.PongIntervalTime)
     {
         return;
     }
     if (this.mIsPong)
     {
         this.mPongCount = 0;
         this.mSocket.Send(this.CreatePingMessage());
     }
     else
     {
         this.mPongCount++;
     }
     this.mIsPong   = false;
     this.mPongTime = Environment.TickCount;
     if (base.PongEndCount < this.mPongCount)
     {
         NpCloudException e = new NpCloudException(750, "Pongにより切断された");
         base.ReceiveException(e);
         this.mIsReceiveThread = false;
     }
 }
 public NpCloudException(NpCloudException e) : base(e.Message, e)
 {
     this.mExitCode = e.ExitCode;
 }