Beispiel #1
0
        public async void Ping()
        {
            if (System.Threading.Interlocked.CompareExchange(ref mPingStatus, 1, 0) == 0)
            {
                if (TcpClient.IsConnected)
                {
                    try
                    {
                        RPCPacket request = new RPCPacket();
                        request.Url = "/__System/Ping";
                        var response = await XRPCClient.SendWait(request, TcpClient, null);

                        PingTime = TimeWatch.GetElapsedMilliseconds();
                    }
                    catch (Exception e_)
                    {
                    }
                    finally
                    {
                        if (TimeOut(XRPCClient.PingTimeout * 1000))
                        {
                            TcpClient.DisConnect();
                            bool isnew;
                            TcpClient.Connect(out isnew);
                        }
                    }
                }
                else
                {
                    PingTime = TimeWatch.GetElapsedMilliseconds();
                }
                System.Threading.Interlocked.Exchange(ref mPingStatus, 0);
            }
        }
Beispiel #2
0
 public async void Ping()
 {
     if (System.Threading.Interlocked.CompareExchange(ref mPingStatus, 1, 0) == 0)
     {
         try
         {
             RPCPacket request = new RPCPacket();
             request.Url = "/__System/Ping";
             var response = await XRPCClient.SendWait(request, TcpClient, null);
         }
         catch (Exception e_)
         {
             mPingError++;
             if (mPingError > 3)
             {
                 mPingError = 0;
                 TcpClient.DisConnect();
             }
         }
         System.Threading.Interlocked.Exchange(ref mPingStatus, 0);
     }
 }
Beispiel #3
0
 public TcpClientItem(AsyncTcpClient client, XRPCClient xrpc)
 {
     TcpClient  = client;
     XRPCClient = xrpc;
 }
 public void Bind(XRPCClient client)
 {
     ClientDelegateProxy = CreateDelegate();
     xRPCClient          = client;
 }