示例#1
0
        public void request(string route, JsonObject msg, Action <JsonObject> action)
        {
            uint id = reqId++;

            this.eventManager.AddCallBack(id, action);
            protocol.send(route, id, msg);
        }
示例#2
0
 /// <summary>
 /// 客户端请求数据,请求成功,获取服务器反馈之后,调用action
 /// </summary>
 /// <param name="route">路由</param>
 /// <param name="msg">携带的信息</param>
 /// <param name="action">回调函数</param>
 public void request(string route, JsonObject msg, Action <JsonObject> action)
 {
     this.eventManager.AddCallBack(reqId, action);
     protocol.send(route, reqId, msg);
     //Log.d ("request pomelo ip=", mIp, " port=", mPort);
     reqId++;
 }
示例#3
0
        public void request(string route, JsonObject msg, Action <Message> action)
        {
            this.eventManager.AddCallBack(reqId, action);
            protocol.send(route, reqId, msg);

            reqId++;
        }
示例#4
0
        public void request(string route, JSONNode msg, Action <JSONNode> action)
        {
            this.eventManager.AddCallBack(reqId, action);
            protocol.send(route, reqId, msg);

            reqId++;
        }
        public void request(object user, Action <JObject> callback)
        {
            byte[] body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(buildMsg(user)));

            protocol.send(PackageType.PKG_HANDSHAKE, body);

            this.callback = callback;
        }
示例#6
0
        public void request(JsonData user, Action <JsonData> callback)
        {
            byte[] body = Encoding.UTF8.GetBytes(JsonMapper.ToJson(buildMsg(user)));

            protocol.send(PackageType.PKG_HANDSHAKE, body);

            this.callback = callback;
        }
示例#7
0
        public void request(JsonObject user, Action <JsonObject> callback)
        {
            byte[] body = Encoding.UTF8.GetBytes(buildMsg(user).ToString());

            protocol.send(PackageType.PKG_HANDSHAKE, body);

            this.callback = callback;
        }
示例#8
0
        public void request(string route, JsonObject msg, Action <JsonObject> action)
        {
            Debug.Log("route =" + route);
            Debug.Log("msg =" + msg);
            Debug.Log("action =" + action);
            Debug.Log("protocol =" + protocol);
            this.eventManager.AddCallBack(reqId, action);
            protocol.send(route, reqId, msg);

            reqId++;
        }
        public void request(string route, JsonObject msg, Action <bool, JsonObject> action)
        {
            if (!inited)
            {
                action(false, null);
                return;
            }

            this.eventManager.AddCallBack(reqId, (obj) => { action(true, obj); });
            protocol.send(route, reqId, msg);

            reqId++;
        }
示例#10
0
        public void request(string route, JsonObject msg, Action <JsonObject> action)
        {
            if (protocol == null || eventManager == null)
            {
                Debug.Log("not init");
                return;
            }

            this.eventManager.AddCallBack(reqId, action);
            protocol.send(route, reqId, msg);

            reqId++;
        }
示例#11
0
        public void request(string route, JsonObject msg, Action <JsonObject> action)
        {
            this.eventManager.AddCallBack(reqId, action);
            protocol.send(route, reqId, msg);

            if (reqId == int.MaxValue)
            {
                reqId = 1;
            }
            else
            {
                reqId++;
            }
        }
示例#12
0
        public void sendHeartBeat(object source, ElapsedEventArgs e)
        {
            TimeSpan span = DateTime.Now - lastTime;

            timeout = (int)span.TotalMilliseconds;

            if (!enabled)
            {
                return;
            }

            Debug.Log("sendHeartBeat");

            //check timeout
            if (timeout > interval + 3000)
            {
                Debug.Log("heartbeat timeout");
                if (protocol.getPomeloClient().GetNetworkState() == NetWorkState.CONNECTED)
                {
                    protocol.getPomeloClient().disconnect();
                }

                stop();
                return;
            }

            //Send heart beat
            protocol.send(PackageType.PKG_HEARTBEAT);
        }
示例#13
0
        public void request(string route, JsonObject msg, Action <Message> action)
        {
            if (netWorkState != NetWorkState.CONNECTED)
            {
                _onError("Network is down, cannot send request now!");
                return;
            }

            UnityEngine.Debug.Log(">>> Send: " + route + " data: " + msg.ToString());

            _eventManager.AddCallback(_reqId, action);
            _protocol.send(route, _reqId, msg);

            _reqId++;
            if (_reqId >= uint.MaxValue)
            {
                _reqId = 100;
            }
        }
示例#14
0
        public void request(uint pid, string route, JsonObject msg, Action <Message> action)
        {
            if (netWorkState != NetWorkState.CONNECTED)
            {
                _onError("Network is down, cannot send request now!");
                return;
            }

            UnityEngine.Debug.Log(">>> Send: " + route + " data: " + msg.ToString());
            if (action == null)
            {
                notify(route, msg);
            }
            else
            {
                if (_eventManager.AddCallback(pid, action))
                {
                    _protocol.send(route, pid, msg);
                }
            }
        }
        public void sendHeartBeat(object source, ElapsedEventArgs e)
        {
            //check timeout
            if (timeout > interval * 2)
            {
                protocol.getPomeloClient().disconnect();
            }

            TimeSpan span = DateTime.Now - lastTime;

            timeout += (int)span.TotalMilliseconds;

            //Send heart beat
            protocol.send(PackageType.PKG_HEARTBEAT);
        }
        public void sendHeartBeat(object source, ElapsedEventArgs e)
        {
            TimeSpan span = DateTime.Now - lastTime;

            timeout = (int)span.TotalMilliseconds;

            //check timeout
            if (timeout > interval * 2)
            {
                Trace.TraceInformation("timeout " + timeout + " > " + interval * 2);
                protocol.getPomeloClient().timeout();
                //stop();
                return;
            }

            //Send heart beat
            protocol.send(PackageType.PKG_HEARTBEAT);
        }
示例#17
0
        public void sendHeartBeat(object source, ElapsedEventArgs e)
        {
            TimeSpan span = DateTime.Now - lastTime;

            timeout = (int)span.TotalMilliseconds;

            //UnityEngine.Debug.Log("timeout:"+timeout.ToString());
            //check timeout
            if (timeout > interval * 2)
            {
                protocol.getPomeloClient().disconnect();
                //stop();
                return;
            }

            //Send heart beat
            protocol.send(PackageType.PKG_HEARTBEAT);
        }