//私聊,目前只支持在线发送 public void CSPrivateChat(IMessage data, int player_id, int addition) { CSPrivateChat protocol = data as CSPrivateChat; ChatPlayer player = this.GetPlayer(player_id); ChatPlayer target_player = this.GetPlayer(protocol.PlayerId); if (player == null || target_player == null) { return; } ChatData chat_data = new ChatData(); chat_data.ChatPlayer = player; chat_data.Content = protocol.Content; chat_data.Time = Global.GetCurTime(); SCPrivateChat msg = new SCPrivateChat(); msg.Data = chat_data; Server.GetInstance().GetSocket().SendToClient(msg, target_player.Id); }
/// <summary> /// 发送聊天信息 私聊 /// </summary> /// <param name="successAction"></param> /// <param name="failedAction"></param> public static void NotifyServerPrivateChatMessage(long uid, string message, Action successAction, Action failedAction) { #if UNITY_EDITOR if (StaticData.IsUsedLocalDataNotServer) { successAction?.Invoke(); return; } #endif CSPrivateChat cSChatMessage = new CSPrivateChat(); cSChatMessage.Message = message; cSChatMessage.Uid = uid; ProtocalManager.Instance().SendCSPrivateChat(cSChatMessage, (SCEmptyPrivateChat sCEmptyPrivateChat) => { Debug.Log("发送聊天信息成功!"); successAction?.Invoke(); }, (ErrorInfo er) => { Debug.Log("通知服务器发送聊天信息:" + er.ErrorMessage); failedAction?.Invoke(); }); }