public IEnumerator Sender_AddQuest_Destroy_AddQuest()
    {
        int      count  = 0;
        FPClient client = new FPClient("52.83.245.22", 13325, 20 * 1000);

        client.Connect();
        yield return(new WaitForSeconds(1.0f));

        FPData data = new FPData();

        data.SetFlag(0x1);
        data.SetMtype(0x1);
        data.SetMethod("which");
        this._sender.AddQuest(client, data, this._payload, (cbd) => {
            count++;
        }, 5 * 1000);
        this._sender.Destroy();
        this._sender.AddQuest(client, this._data, this._payload, (cbd) => {
            count++;
        }, 5 * 1000);
        yield return(new WaitForSeconds(1.0f));

        this._sender.Destroy();
        client.Close();
        yield return(new WaitForSeconds(1.0f));

        Assert.AreEqual(1, count);
    }
        public void Destroy()
        {
            this._session    = 0;
            this._pingEid    = 0;
            this._writeCount = 0;

            this._pid   = 0;
            this._token = null;
            this._uid   = null;
            this._appv  = null;

            this._lastPingTime    = 0;
            this._lastSendTime    = 0;
            this._lastConnectTime = 0;

            this._pingLatency   = 0;
            this._configVersion = 0;

            if (this._baseClient != null)
            {
                this._baseClient.Destroy();
                this._baseClient = null;
            }

            if (this._rumEvent != null)
            {
                this._rumEvent.Destroy();
            }

            this._event.RemoveListener();
            RUMPlatform.Instance.GetEvent().RemoveListener();
        }
示例#3
0
        private void CheckInBackground()
        {
            if (_isPause && !_isFocus)
            {
                if (_isBackground == false)
                {
                    _isBackground = true;

#if UNITY_IOS
                    FPClient.AppleMobileDeviceSwitchToBackground(_isBackground);
#endif
                }
            }
            else
            {
                if (_isBackground)
                {
                    _isBackground = false;

#if UNITY_IOS
                    FPClient.AppleMobileDeviceSwitchToBackground(_isBackground);
#endif
                }
            }
        }
示例#4
0
    public void TearDown()
    {
        if (this._sender != null)
        {
            this._sender.Destroy();
            this._sender = null;
        }

        if (this._client != null)
        {
            this._client.Close();
            this._client = null;
        }
    }
 public void SetUp()
 {
     RTMRegistration.Register();
     this._sender  = new RTMSender();
     this._client  = new FPClient("52.83.245.22", 13325, 20 * 1000);
     this._payload = new Dictionary <string, object>()
     {
         { "pid", 11000001 },
         { "uid", 777779 },
         { "what", "rtmGated" },
         { "addrType", "ipv4" },
         { "version", null }
     };
     this._data = new FPData();
     this._data.SetFlag(0x1);
     this._data.SetMtype(0x1);
     this._data.SetMethod("which");
 }
    public IEnumerator Sender_AddQuest()
    {
        int      count  = 0;
        FPClient client = new FPClient("52.83.245.22", 13325, 20 * 1000);

        client.Connect();
        yield return(new WaitForSeconds(1.0f));

        this._sender.AddQuest(client, this._data, this._payload, (cbd) => {
            count++;
        }, 5 * 1000);
        yield return(new WaitForSeconds(2.0f));

        this._sender.Destroy();
        client.Close();
        yield return(new WaitForSeconds(1.0f));

        Assert.AreEqual(1, count);
    }
示例#7
0
        public void AddQuest(FPClient client, FPData data, IDictionary <string, object> payload, CallbackDelegate callback, int timeout)
        {
            if (data == null)
            {
                if (callback != null)
                {
                    callback(new CallbackData(new Exception("data is null!")));
                }
                return;
            }

            this.AddService(() => {
                if (client != null)
                {
                    byte[] bytes = new byte[0];

                    try {
                        using (MemoryStream outputStream = new MemoryStream()) {
                            MsgPack.Serialize(payload, outputStream);
                            outputStream.Seek(0, SeekOrigin.Begin);
                            bytes = outputStream.ToArray();
                        }
                    } catch (Exception ex) {
                        ErrorRecorderHolder.recordError(ex);

                        if (callback != null)
                        {
                            callback(new CallbackData(ex));
                        }

                        return;
                    }

                    data.SetPayload(bytes);
                    client.SendQuest(data, callback, timeout);
                }
            });
        }
        public void Connect(string endpoint, bool clearRumId, bool clearEvents)
        {
            if (this._baseClient != null)
            {
                this.GetEvent().FireEvent(new EventData("error", new Exception("client has been init!")));
                return;
            }

            if (clearRumId)
            {
                this._rumEvent.ClearRumId();
            }

            if (clearEvents)
            {
                this._rumEvent.ClearEvents();
            }

            if (this._debug)
            {
                Debug.Log("[RUM] init: " + endpoint);
            }

            this.OpenEvent();

            RUMClient self = this;

            ThreadPool.Instance.StartTimerThread();

            this._baseClient = new FPClient(endpoint, false, RUMConfig.CONNCT_INTERVAL);

            this._baseClient.GetEvent().AddListener("connect", (evd) => {
                if (self._debug)
                {
                    Debug.Log("[RUM] connect on rum agent!");
                }

                self.GetEvent().FireEvent(new EventData("ready"));

                self.StartPing();
                self.StartSend();
            });

            this._baseClient.GetEvent().AddListener("close", (evd) => {
                if (self._debug)
                {
                    Debug.Log("[RUM] close from rum agent!");
                }

                self.StopPing();
                self.StopSend();

                self._lastConnectTime = ThreadPool.Instance.GetMilliTimestamp();
                self.GetEvent().FireEvent(new EventData("close"));
            });

            this._baseClient.GetEvent().AddListener("error", (evd) => {
                if (self._debug)
                {
                    Debug.Log("[RUM] error: " + evd.GetException().Message);
                }

                self.GetEvent().FireEvent(new EventData("error", evd.GetException()));
            });

            this._baseClient.GetEvent().AddListener("second", (evd) => {
                self.OnSecond(evd.GetTimestamp());
            });

            this._baseClient.Connect();
        }
示例#9
0
 public void SetUp()
 {
     this._sender = new RTMSender();
     this._client = new FPClient("52.83.245.22", 13325, 20 * 1000);
 }