/// <summary> /// 聊天计费 /// </summary> /// <param name="client"></param> /// <param name="buffer"></param> private void ProChatFee(CommuTcpClient client, byte[] buffer) { ChatFee chatFee = new ChatFee(buffer); OnRaiseMsgRecvEvent(client, chatFee.ToString()); ChatFeeResp chatFeeResp = new ChatFeeResp(chatFee.Header.Sequence_Id); //处理计费业务 List <PushPDian> pushPList = new List <PushPDian>(); var result = (true, ""); var key = client.Nodeid.ToString() + chatFee.Header.Sequence_Id; var chatFeeHis = pXinDb.GetChatFeeHisBySeq(client.Nodeid.ToString() + chatFee.Header.Sequence_Id); if (chatFeeHis.Hisid == 0)//判断是否是丢包情况重发 { if (!string.IsNullOrEmpty(chatFee.Body.Receiver)) { result = HandChatFeeBusiness(chatFee, client.Nodeid, pushPList); } else { result = (false, "无效参数:Receiver"); } } var tpxinUserinfo = pXinDb.GetUserInfoByNodeId(client.Nodeid); chatFeeResp.Body.FeeType = chatFee.Body.FeeType; chatFeeResp.Body.Status = result.Item1 == true?Convert.ToUInt32(1) : Convert.ToUInt32(0); chatFeeResp.Body.StatusDesc = result.Item1 == true ? "成功" : result.Item2; chatFeeResp.Body.VDianBalance = tpxinUserinfo.V; chatFeeResp.Body.PDianBalance = tpxinUserinfo.P; client.SendData(chatFeeResp.ToBytes()); if (result.Item1) { if (chatFee.Body.ReceiveType == 1)//接收者类型为用户 { int receiverid = 0; Int32.TryParse(chatFee.Body.Receiver, out receiverid); var pushPDian = pushPList.FirstOrDefault(p => p.NodeId == receiverid); PushReceive(pushPDian); } else if (chatFee.Body.ReceiveType == 2 || chatFee.Body.ReceiveType == 3) //接收者类型为群时 { foreach (var item in pushPList) //遍历群成员进行推送 { PushReceive(item); } } } }
public bool SendChatFee(uint ReceiveType = 1, string Receiver = "4242292") { ChatFee chatFee = new ChatFee(); Random random = new Random(); chatFee.Body = new ChatFeeBody { BusinessType = (uint)random.Next(1, 6), FeeType = (uint)random.Next(1, 3), Num = (uint)random.Next(1, 20), ReceiveType = ReceiveType, Receiver = Receiver, //ReceiveType = (uint)2, //Receiver = "449", FeeTime = DateTime.Now, Rate = random.Next(1, 10) }; SendData(chatFee.ToBytes()); OnRaiseMsgSendEvent(chatFee.Header.Command_Id, chatFee, "发送消息:" + chatFee.ToString()); return(true); }
/// <summary> /// 聊天包重复发送 /// </summary> /// <param name="ReceiveType"></param> /// <param name="Receiver"></param> /// <returns></returns> public bool SendChatFeeRepeat() { ChatFee chatFee = new ChatFee(); chatFee.Header.Sequence_Id = 2019110818353116; Random random = new Random(); chatFee.Body = new ChatFeeBody { BusinessType = (uint)random.Next(1, 6), FeeType = (uint)random.Next(1, 3), Num = (uint)random.Next(1, 20), ReceiveType = 1, Receiver = "2000", //ReceiveType = (uint)2, //Receiver = "449", FeeTime = DateTime.Now, Rate = random.Next(1, 10) }; SendData(chatFee.ToBytes()); OnRaiseMsgSendEvent(chatFee.Header.Command_Id, chatFee, "发送消息:" + chatFee.ToString()); return(true); }