Esempio n. 1
0
 public bool SendRoot <T>(byte command, String Request, T Root, int Querycount)
 {
     WeaveBase.WeaveSession b = new WeaveBase.WeaveSession();
     b.Request = Request;
     b.Token   = this.Tokan;
     b.SetRoot <T>(Root);
     b.Querycount = Querycount;
     return(send(command, b.Getjson()));
 }
Esempio n. 2
0
 public bool SendParameter <T>(byte command, String Request, T Parameter, int Querycount)
 {
     WeaveBase.WeaveSession b = new WeaveBase.WeaveSession();
     b.Request = Request;
     b.Token   = this.Tokan;
     b.SetParameter <T>(Parameter);
     b.Querycount = Querycount;
     return(send(command, b.Getjson()));
 }
 public bool SendDtu(Socket soc, byte[] Root, String ip, int port)
 {
     WeaveBase.WeaveSession b = new WeaveBase.WeaveSession();
     b.Request = "dtu";
     b.Token   = ip + "|" + port;
     b.SetRoot <byte[]>(Root);
     b.Querycount = 0;
     return(Send(soc, 0x00, b.Getjson()));
 }
        public bool SendRoot <T>(Socket soc, byte command, String Request, T Root, int Querycount, String Tokan)
        {
            WeaveBase.WeaveSession b = new WeaveBase.WeaveSession();
            b.Request = Request;
            b.Token   = Tokan;
            b.SetRoot <T>(Root);
            b.Querycount = Querycount;
            bool sendok = Send(soc, command, b);

            if (!sendok)
            {
                return(Send(soc, command, b.Getjson()));
            }
            return(sendok);
        }
Esempio n. 5
0
        protected void ReloadFliesway(object obj)
        {
            try
            {
                foreach (WayItem ci in WayItemS)
                {
                    ci.Client.stop();
                }
                WayItemS.Clear();
                XmlDocument xml = new XmlDocument();
                xml.Load("nodeway.xml");
                foreach (XmlNode xn in xml.FirstChild.ChildNodes)
                {
                    WayItem ci = new WayItem();
                    ci.Ip     = xn.Attributes["ip"].Value;
                    ci.Port   = Convert.ToInt32(xn.Attributes["port"].Value);
                    ci.Token  = (xn.Attributes["token"].Value);
                    ci.Client = new P2Pclient(false);
                    ci.Client.receiveServerEvent += Client_receiveServerEvent;
                    ci.Client.timeoutobjevent    += Client_timeoutobjevent;

                    ci.Client.ErrorMge += Client_ErrorMge;
                    if (ci.Client.start(ci.Ip, ci.Port, false))
                    {
                        WeaveBase.WeaveSession oxff = new WeaveBase.WeaveSession();
                        oxff.Request = "token";
                        oxff.Root    = ci.Token;
                        ci.Client.send(0xff, oxff.Getjson());
                        WayItemS.Add(ci);
                    }
                    else
                    {
                        if (EventMylog != null)
                        {
                            EventMylog("从网关连接失败", "从网关:" + ci.Ip + ":节点连接失败,抛弃此节点");
                        }
                    }
                }
                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(getwaynum));
            }
            catch (Exception ex)
            {
                if (EventMylog != null)
                {
                    EventMylog("加载异常", ex.Message);
                }
            }
        }
Esempio n. 6
0
 public void getwaynum(object obj)
 {
     while (true)
     {
         try
         {
             int       count  = WayItemS.Count;
             WayItem[] coobjs = new WayItem[count];
             WayItemS.CopyTo(0, coobjs, 0, count);
             foreach (WayItem wi in coobjs)
             {
                 WeaveBase.WeaveSession oxff = new WeaveBase.WeaveSession();
                 oxff.Request = "getnum";
                 oxff.Root    = wi.Token;
                 wi.Client.send(0xff, oxff.Getjson());
             }
         }
         catch { }
         System.Threading.Thread.Sleep(2000);
     }
 }