示例#1
0
        public EtzelClient(string host)
        {
            ws = new WebSocket(host);
            using ( ws ) {
                ws.OnMessage += (sender, e) => {
                    //Console.WriteLine (e.Data);
                    stupid s = JsonConvert.DeserializeObject <stupid>(e.Data);
                    if (s.cmd == "nomsg")
                    {
                        this.isleep(s.qname);
                    }
                    if (s.cmd == "awk")
                    {
                        this.fetch(s.qname);
                    }
                    if (s.cmd == "msg")
                    {
                        this.qbacks[s.qname](s);
                        this.fetch(s.qname);
                    }
                };
            }

            ws.Connect();
        }
示例#2
0
        public void acknowledge(string qname,string uid)
        {
            stupid s = new stupid();
            s.qname = qname;
            s.cmd = "ACK";
            string data = JsonConvert.SerializeObject(s);

            ws.Send(data);
        }
示例#3
0
        public void fetch(string qname)
        {
            stupid s = new stupid();

            s.qname = qname;
            s.cmd   = "FET";
            string data = JsonConvert.SerializeObject(s);

            this.ws.Send(data);
        }
示例#4
0
        public void acknowledge(string qname, string uid)
        {
            stupid s = new stupid();

            s.qname = qname;
            s.cmd   = "ACK";
            string data = JsonConvert.SerializeObject(s);

            ws.Send(data);
        }
示例#5
0
        public void isleep(string qname)
        {
            stupid s = new stupid();

            s.qname = qname;
            s.cmd   = "ISLP";
            string data = JsonConvert.SerializeObject(s);

            ws.Send(data);
        }
示例#6
0
        public void publish(string qname, string message, object options = null)
        {
            stupid s = new stupid();

            s.qname = qname;
            s.cmd   = "PUB";
            s.msg   = message;
            string data = JsonConvert.SerializeObject(s);

            //Console.WriteLine(data);

            ws.Send(data);
        }
示例#7
0
        public void isleep(string qname)
        {
            stupid s = new stupid();
            s.qname = qname;
            s.cmd = "ISLP";
            string data = JsonConvert.SerializeObject(s);

            ws.Send(data);
        }
示例#8
0
        public void fetch(string qname)
        {
            stupid s = new stupid();
            s.qname = qname;
            s.cmd = "FET";
            string data = JsonConvert.SerializeObject(s);

            this.ws.Send(data);
        }
示例#9
0
        public void publish(string qname, string message, object options=null)
        {
            stupid s = new stupid();
            s.qname = qname;
            s.cmd = "PUB";
            s.msg = message;
            string data = JsonConvert.SerializeObject(s);

            //Console.WriteLine(data);

            ws.Send(data);
        }