예제 #1
0
        public bool SendRoot <T>(byte command, String Request, T Root, int Querycount)
        {
            WeaveSession b = new WeaveSession();

            b.Request = Request;
            b.Token   = this.Tokan;
            b.SetRoot <T>(Root);
            b.Querycount = Querycount;
            return(send(command, b.Getjson()));
        }
예제 #2
0
        public bool SendParameter <T>(byte command, String Request, T Parameter, int Querycount)
        {
            WeaveSession b = new WeaveSession();

            b.Request = Request;
            b.Token   = this.Tokan;
            b.SetParameter <T>(Parameter);
            b.Querycount = Querycount;
            return(send(command, b.Getjson()));
        }
예제 #3
0
 private void P2psev_receiveeventbit(byte command, byte[] data, System.Net.Sockets.Socket soc)
 {
     try
     {
         // JSON.parse<_baseModel>(data);//
         WeaveSession _0x01 = null;
         try
         {
             foreach (WeaveTcpToken itp in TcpTokenList)
             {
                 if (itp.PortType == WeavePortTypeEnum.Bytes)
                 {
                     _0x01 = itp.BytesDataparsing.GetBaseModel(data);//二进制转_baseModel
                     if (command == 0xff)
                     {
                         WeaveExcCmdNoCheckCmdName(command, _0x01.Getjson(), soc);
                     }
                     else
                     {
                         if (itp.BytesDataparsing.Socketvalidation(_0x01)) //验证_baseModel
                         {
                             WeaveExcCmd(command, _0x01.Getjson(), soc);
                         }
                     }
                 }
             }
         }
         catch
         {
             WeaveLogEvent("JSON解析错误:", "" + data);
             return;
         }
     }
     catch (Exception ex)
     {
         if (WeaveLogEvent != null)
         {
             WeaveLogEvent("p2psev_receiveevent----", ex.Message);
         }
     }
 }
예제 #4
0
        public bool SendRoot <T>(byte command, string Request, T Root, int Querycount)
        {
            WeaveSession b = new WeaveSession
            {
                Request = Request,
                Token   = Tokan
            };

            b.SetRoot(Root);
            b.Querycount = Querycount;
            return(Send(command, b.Getjson()));
        }
예제 #5
0
        public bool SendParameter <T>(byte command, string Request, T Parameter, int Querycount)
        {
            WeaveSession b = new WeaveSession
            {
                Request = Request,
                Token   = Tokan
            };

            b.SetParameter(Parameter);
            b.Querycount = Querycount;
            return(Send(command, b.Getjson()));
        }
예제 #6
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))
                    {
                        WeaveSession oxff = new 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);
                }
            }
        }
예제 #7
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)
             {
                 WeaveSession oxff = new WeaveSession();
                 oxff.Request = "getnum";
                 oxff.Root    = wi.Token;
                 wi.Client.send(0xff, oxff.Getjson());
             }
         }
         catch { }
         System.Threading.Thread.Sleep(2000);
     }
 }
예제 #8
0
 protected void P2psev2_receiveevent(byte command, string data, Socket soc)
 {
     try
     {
         WeaveSession _0x01 = Newtonsoft.Json.JsonConvert.DeserializeObject <WeaveSession>(data);
         if (command == 0xff)
         {
             if (_0x01.Request == "token")
             {
                 token = _0x01.Root;
             }
             else if (_0x01.Request == "getnum")
             {
                 _0x01.Request = "setnum";
                 _0x01.Token   = token;
                 _0x01.Root    = getnum().ToString();
                 p2psev2.Send(soc, 0xff, _0x01.Getjson());
             }
         }
     }
     catch { }
 }
예제 #9
0
 public void login(Socket soc, WeaveSession _0x01)
 {
     Send(soc, 0x01, _0x01.Getjson());
 }