internal override void SendMsg(RfConnectE connectE, string ip, string meid, RfPackage pack) { mMsg.IP = ip; mMsg.MEID = meid; mMsg.Conn = connectE; mMsg.Pack = pack; Messenger.Default.Send(mMsg, MsgToken.RfMsgUpdate); }
internal override void NoticeDataReceive(byte[] data, RfClientTcp client) { try { string dstr = Encoding.UTF8.GetString(data); RfPackage package = JsonTool.Deserialize <RfPackage>(dstr); if (!client.IsUpdateMEID) { client.SetMEID(package.Meid); } package.ClientId = client.MEID; SendMsg(RfConnectE.客户端接收信息, client.IP_PORT, client.MEID, package); _mLog.Status(true, string.Format("[Send]-Client:{0}\n" + "Msg:{1}", client.MEID, dstr)); }catch (Exception e) { _mLog.Error(true, e.StackTrace); } }
/// <summary> /// 发送数据 /// </summary> /// <param name="msg"></param> public bool SendMessage(string clientid, RfPackage pack) { if (pack == null) { string logMessage = "Cannot send empty message"; throw new ArgumentNullException(logMessage); } string dstr = JsonTool.Serialize(pack); byte[] data = Encoding.UTF8.GetBytes(dstr); int msgsize = data.Length + 8; byte[] msg = ShiftBytes(BitConverter.GetBytes(P_HEAD), 0, 2) .Concat(ShiftBytes(BitConverter.GetBytes(msgsize), 0, 4)) .Concat(data) // message data .Concat(ShiftBytes(BitConverter.GetBytes(P_TAIL), 0, 2)) // tailKey .ToArray(); //_mLog.Status(true, string.Format("[Send]-Client:{0}\n" + "Msg:{1}", clientid, dstr)); return(SendSameClient(clientid, msg)); }
internal abstract void SendMsg(RfConnectE connectE, string ip, string meid, RfPackage pack);