public bool SendDtu(Socket soc, byte[] Root, String ip, int port) { WeaveSession b = new WeaveSession(); b.Request = "dtu"; b.Token = ip + "|" + port; b.SetRoot <byte[]>(Root); b.Querycount = 0; return(Send(soc, 0x00, b.Getjson())); }
public bool Send(Socket soc, byte command, WeaveSession b) { foreach (WeaveTcpToken itp in WeaveTcpTokenList) { if (itp.P2Server.Port == ((System.Net.IPEndPoint)soc.LocalEndPoint).Port) { if (itp.PortType == WeavePortTypeEnum.Bytes) { return(itp.P2Server.Send(soc, command, itp.BytesDataparsing.Get_Byte(b))); } } } return(false); }
/// <summary> /// 错误返回事件 /// </summary> public void Init(String data, Socket soc) { WeaveSession _0x01 = Newtonsoft.Json.JsonConvert.DeserializeObject <WeaveSession>(data); string message = ""; try { if (_0x01 != null && _0x01.Token != "") { int count = listmode.Count; WeaveModelData[] mds = new WeaveModelData[count]; listmode.CopyTo(mds); foreach (WeaveModelData md in mds) { if (md.Request == _0x01.Request) { if (md.rd2 != null && md.dtu == true) { WeaveRequestDataDtuDelegate rdh = new WeaveRequestDataDtuDelegate(md.rd2); byte[] b = Newtonsoft.Json.JsonConvert.DeserializeObject <byte[]>(_0x01.Root); rdh(soc, b, _0x01.Token.Split('|')[0], Convert.ToInt32(_0x01.Token.Split('|')[1])); if (md.type == "once") { listmode.Remove(md); } } if (md.rd != null && md.dtu == false) { //md.rd(soc, _0x01); WeaveRequestDataDelegate rdh = new WeaveRequestDataDelegate(md.rd); rdh(soc, _0x01); if (md.type == "once") { listmode.Remove(md); } } } } //根据具体功能不同,代码不同 //if (RequestDataEvent != null) // RequestDataEvent(soc, _0x01,_0x01.Request); } } catch (Exception ex) { _0x01.Parameter = ex.Message; message = Newtonsoft.Json.JsonConvert.SerializeObject(_0x01); WeaveErrorMessageEvent(soc, _0x01, ex.Message); } }
public bool SendRoot <T>(Socket soc, byte command, String Request, T Root, int Querycount, String Tokan) { WeaveSession b = new 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); }
public bool SendParameter <T>(Socket soc, byte command, string Request, T Parameter, int Querycount, string Tokan) { WeaveSession b = new WeaveSession { Request = Request, Token = Tokan }; b.SetParameter(Parameter); b.Querycount = Querycount; bool sendok = Send(soc, command, b); if (!sendok) { return(Send(soc, command, b.Getjson())); } return(sendok); }
public abstract void WeaveBaseErrorMessageEvent(Socket soc, WeaveSession _0x01, string message);