/// <summary> /// 聊天计费倍率设置 /// </summary> /// <param name="client"></param> /// <param name="buffer"></param> private void ProChatFeeRateSet(CommuTcpClient client, byte[] buffer) { ChatFeeRateSet chatFeeRateSet = new ChatFeeRateSet(buffer); OnRaiseMsgRecvEvent(client, chatFeeRateSet.ToString()); TchatRate tchatRate = new TchatRate(); tchatRate.Typeid = chatFeeRateSet.Body.Type; tchatRate.Sender = chatFeeRateSet.Body.Sender;//0; tchatRate.Receiver = chatFeeRateSet.Body.Receiver; tchatRate.Rate = chatFeeRateSet.Body.Rate; tchatRate.Createtime = DateTime.Now; tchatRate.Remarks = "聊天计费倍率设置"; var flag = true; var result = pXinDb.GetTchatRate(tchatRate.Sender, tchatRate.Receiver, tchatRate.Typeid); if (result.Id == 0) { if (tchatRate.Rate > 1) { flag = pXinDb.ChatFeeRateSet(tchatRate); } } else { flag = pXinDb.UpdateChatFeeRate(tchatRate); } tchatRate.Rate = flag == false ? result.Rate : tchatRate.Rate; ChatFeeRateSetResp chatFeeRateSetResp = new ChatFeeRateSetResp(chatFeeRateSet.Header.Sequence_Id); chatFeeRateSetResp.Body.Status = flag == true ? (uint)1 : 0; chatFeeRateSetResp.Body.Rate = tchatRate.Rate; client.SendData(chatFeeRateSetResp.ToBytes()); //推送 RateSetPush(client.Nodeid, chatFeeRateSet, tchatRate); }
private void ProChatFeeRateSetResp() { ChatFeeRateSetResp chatFeeRateSetResp = new ChatFeeRateSetResp(_buffer); OnRaiseMsgRecvEvent(chatFeeRateSetResp.Header.Command_Id, chatFeeRateSetResp, "接收消息:" + chatFeeRateSetResp.ToString()); }
private void OnRaiseMsgSendEvent(byte[] buffer) { if (MsgSendEventHandler != null) { string msg = string.Empty; MessageHeader header = new MessageHeader(buffer); switch (header.Command_Id) { case PXin_COMMAND_TYPE.Login: msg = new Login(buffer).ToString(); break; case PXin_COMMAND_TYPE.LoginResp: msg = new LoginResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.Logout: msg = new Wt_Logout(buffer).ToString(); break; case PXin_COMMAND_TYPE.LogoutResp: msg = new LogoutResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.Active: msg = new Active(buffer).ToString(); break; case PXin_COMMAND_TYPE.ActiveResp: msg = new ActiveResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFee: msg = new ChatFee(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeResp: msg = new ChatFeeResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeePush: msg = new ChatFeePush(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeRateSet: msg = new ChatFeeRateSet(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeRateSetResp: msg = new ChatFeeRateSetResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeRateQuery: msg = new ChatFeeRateQuery(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeRateQueryResp: msg = new ChatFeeRateQueryResp(buffer).ToString(); break; default: break; } //发布"消息发送"事件 if (header.Command_Id != PXin_COMMAND_TYPE.Active && header.Command_Id != PXin_COMMAND_TYPE.ActiveResp) { MsgSendEventHandler?.Invoke(this, new MessageEventArgs(string.Empty, Identity, msg)); } } }