public void SendChatMessage(string str) { BattleChatC2S message = new BattleChatC2S(); message.battleChatType = BattleChatType.match; //Just send 30 length string. if (str.Length > 30) { str = str.Substring(0, 30); } message.chatContent = str; for (int i = 0; i < view.firendID.Count; i++) { message.playerId.Add(view.firendID[i]); } byte[] stream = ProtobufUtils.Serialize(message); NetworkManager.SendRequest(ServerType.SocialServer, MsgCode.BattleChatsMessage, stream); }
public void SendChatMessage(string str, BattleChatType type) { if (dataManager.CurBattleIsPVE()) { return; } BattleChatC2S message = new BattleChatC2S(); List <long> enemyPlayerID = new List <long>(); if (friendlyPlayerID == -1) { List <Battler> list = dataManager.GetBattlers(); MatchSide side = dataManager.GetMatchSide(); long playerID = dataManager.GetPlayerId(); for (int i = 0; i < list.Count; i++) { if (list[i].side == side && list[i].playerId != playerID) { friendlyPlayerID = list[i].playerId; friendlyPlayerName = list[i].name; } else if (list[i].side != side) { enemyPlayerID.Add(list[i].playerId); enemyNames.Add(list[i].name); } } } if (type == BattleChatType.party) { message.battleChatType = BattleChatType.party; message.playerId.Add(friendlyPlayerID); } else if (type == BattleChatType.everyone) { message.battleChatType = BattleChatType.everyone; if (friendlyPlayerID != -1) { message.playerId.Add(friendlyPlayerID); } for (int i = 0; i < enemyPlayerID.Count; i++) { message.playerId.Add(enemyPlayerID[i]); } } else { //TODO: If have more type chat channel add here. DebugUtils.LogError(DebugUtils.Type.Chat, "Please check chat Type."); } message.chatContent = str; byte[] stream = ProtobufUtils.Serialize(message); NetworkManager.SendRequest(ServerType.SocialServer, MsgCode.BattleChatsMessage, stream); }