Ejemplo n.º 1
0
        public void SendProtocol()
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            foreach (KVString kv in arguments)
            {
                args.Add(kv.key, kv.val);
            }
            HoxisProtocol proto = new HoxisProtocol
            {
                type   = protocolType,
                handle = FF.ObjectToJson(new ReqHandle {
                    req = method, ts = SF.GetTimeStamp(TimeUnit.Millisecond)
                }),
                err      = error,
                receiver = new HoxisProtocolReceiver {
                    type = receiverType, uid = receiverUID
                },
                sender = new HoxisProtocolSender {
                    uid = senderUID, aid = senderAgentID, loopback = loopback
                },
                action = new HoxisProtocolAction(method, new HoxisProtocolArgs(args)),
                desc   = description
            };

            HoxisDirector.Ins.ProtocolPost(proto);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Post a protocol to client
        /// </summary>
        /// <param name="proto"></param>
        public void ProtocolPost(HoxisProtocol proto)
        {
            string json = FF.ObjectToJson(proto);

            byte[] data = FF.StringToBytes(json);
            OnPost(data);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Rapidly send a request protocol
        /// </summary>
        /// <param name="method"></param>
        /// <param name="kvs"></param>
        public void Request(string method, params KVString[] kvs)
        {
            HoxisProtocol proto = new HoxisProtocol
            {
                type   = ProtocolType.Request,
                handle = FF.ObjectToJson(new ReqHandle {
                    req = method, ts = SF.GetTimeStamp(TimeUnit.Millisecond)
                }),
                err      = "",
                receiver = HoxisProtocolReceiver.undef,
                sender   = HoxisProtocolSender.undef,
                action   = new HoxisProtocolAction(method, kvs),
                desc     = ""
            };

            ProtocolPost(proto);
            // todo wait for response
        }
Ejemplo n.º 4
0
        // Use this for initialization
        void Start()
        {
            HoxisDirector.Ins.onResponseError        += (err, desc) => { LogAffairEntry(FF.StringFormat("response err: {0}, {1}", err, desc), LogLevel.Error); };
            HoxisDirector.Ins.onProtocolEntry        += (proto) => { LogAffairEntry(FF.StringFormat("protocol entry: {0}", FF.ObjectToJson(proto))); };
            HoxisDirector.Ins.onProtocolPost         += (proto) => { LogAffairEntry(FF.StringFormat("protocol post: {0}", FF.ObjectToJson(proto))); };
            HoxisDirector.Ins.onAffairInitError      += (ret) => { LogAffairEntry(ret.desc, LogLevel.Error); };
            HoxisDirector.Ins.onAffairConnected      += () => { LogAffairEntry(FF.StringFormat("connect to {0}", HoxisClient.Ins.serverIP)); };
            HoxisDirector.Ins.onAffairConnectError   += (ret) => { LogAffairEntry(ret.desc, LogLevel.Error); };
            HoxisDirector.Ins.onAffairClosed         += () => { LogAffairEntry("close success"); };
            HoxisDirector.Ins.onAffairClosedError    += (ret) => { LogAffairEntry(ret.desc, LogLevel.Error); };
            HoxisDirector.Ins.onAffairNetworkAnomaly += (ret) => { LogAffairEntry(ret.desc, LogLevel.Error); };

            _logPanel.GetComponent <RectTransform>().localPosition = _logPanelOffPosition;
            _logPanelOn = false;

            HoxisDirector.Ins.AwakeIns();
        }