Exemplo n.º 1
0
        public void request(string protocol, string version, JObject obj, Action <JObject> respon, bool subscribe = false)
        {
            var requt = new
            {
                Protocol = protocol,
                ReqParam = obj,
                Version  = version
            };

            if (!callBackDictionary.ContainsKey(protocol))
            {
                callBackDictionary.Add(protocol, new List <callbackEvent>());
            }

            callbackEvent cbe = new callbackEvent();

            cbe.obj         = obj;
            cbe.respon      = respon;
            cbe.isSubscribe = subscribe;
            callBackDictionary[protocol].Add(cbe);

            string requt_str = JsonConvert.SerializeObject(requt);

            _mySock[getDataLine(protocol)].Send(encoding.GetBytes(requt_str + "\r\n"));
            Debug.info("Send [" + getDataLine(protocol) + "] : " + requt_str);
        }
Exemplo n.º 2
0
        public string pustCallback(string _protocol, JObject obj, Action <JObject> respon)
        {
            string        uid      = getCookie();
            string        protocol = _protocol;
            callbackEvent cbe      = new callbackEvent();

            cbe.obj         = obj;
            cbe.respon      = respon;
            cbe.isSubscribe = true;

            if (!callBackDictionary.ContainsKey(protocol))
            {
                callBackDictionary.Add(protocol, new List <callbackEvent>());
            }

            callBackDictionary[protocol].Add(cbe);

            return(uid);
        }