/// <summary> /// 收到客户端发来的消息,并转发到服务端中心 /// </summary> /// <param name="command"></param> /// <param name="data"></param> /// <param name="soc"></param> protected void p2psev_receiveevent(byte command, string data, System.Net.Sockets.Socket soc) { try { // JSON.parse<_baseModel>(data);// WeaveBase.WeaveSession _0x01; try { _0x01 = Newtonsoft.Json.JsonConvert.DeserializeObject <WeaveSession>(data); } catch { EventMylog("JSON解析错误:", "" + data); return; } if (_0x01.Token == null) { EventMylog("Token是NULL:", "" + data); return; } IPEndPoint clientipe = (IPEndPoint)soc.RemoteEndPoint; int count = CommandItemS.Count; try { // temp = _0x01.Token.Split(':'); //if (temp.Length < 2) // return; _0x01.Token = clientipe.Address.ToString() + ":" + clientipe.Port; } catch (Exception e) { if (EventMylog != null) { EventMylog("p2psev_receiveevent", e.Message); } return; } foreach (GateWayCommandItem ci in CommandItemS) { if (ci != null) { if (ci.CommName == command) { P2Pclient[,,,] client = ci.Client; P2Pclient p2ptemp = GateHelper.GetP2Pclient(client, soc, Pipeline); if (p2ptemp != null) { if (!p2ptemp.Isline) { p2psev.Send(soc, 0xff, "你所请求的服务暂不能使用,已断开连接!"); return; } if (!p2ptemp.send(command, _0x01.Getjson())) { p2psev.Send(soc, 0xff, "你所请求的服务暂不能使用,发送错误。"); } } } } } } catch (Exception ex) { if (EventMylog != null) { EventMylog("p2psev_receiveevent----", ex.Message); } } }
/// <summary> /// 收到客户端发来的Byte消息,并转发到服务端中心 /// </summary> /// <param name="command"></param> /// <param name="data"></param> /// <param name="soc"></param> private void P2psev_weaveReceiveBitEvent(byte command, byte[] data, Socket soc) { try { // JSON.parse<_baseModel>(data);// IPEndPoint clientipe = (IPEndPoint)soc.RemoteEndPoint; int count = CommandItemS.Count; try { // temp = _0x01.Token.Split(':'); //if (temp.Length < 2) // return; //_0x01.Token = clientipe.Address.ToString() + ":" + clientipe.Port; } catch (Exception e) { if (EventMylog != null) { EventMylog("p2psev_receiveevent", e.Message); } return; } foreach (GateWayCommandItem ci in CommandItemS) { if (ci != null) { if (ci.CommName == command) { P2Pclient[,,,] client = ci.Client; P2Pclient p2ptemp = GateHelper.GetP2Pclient(client, soc, Pipeline); byte [] b = GateHelper.GetP2PclientIndex(client, soc, Pipeline); if (p2ptemp != null) { if (!p2ptemp.Isline) { p2psev.Send(soc, 0xff, "你所请求的服务暂不能使用,已断开连接!"); return; } byte[] tempdata = new byte[data.Length + b.Length]; Array.Copy(data, 0, tempdata, 0, data.Length); Array.Copy(b, 0, tempdata, data.Length - 1, b.Length); if (!p2ptemp.send(command, tempdata)) { p2psev.Send(soc, 0xff, "你所请求的服务暂不能使用,发送错误。"); } } } } } } catch (Exception ex) { if (EventMylog != null) { EventMylog("p2psev_receiveevent----", ex.Message); } } }