Exemple #1
0
        // -------------------------------------------------------------------------------
        public void OnServerChatReceive(NetworkConnection conn, MsgChatSendFromClient msg)
        {
            ChatChannelData channel = defaultChannel;

            if (ChatUsers.ContainsKey(conn))
            {
                ChatUser user = ChatUsers[conn];
                if (Channels.ContainsKey(msg.channelId))
                {
                    channel = Channels[msg.channelId];
                }
                else
                {
                    Debug.LogWarning("[Warning] Chat channel (" + msg.channelId + ") not found");
                }

                if (channel != null)
                {
                    ClientChatReceive(channel.DoChatLogic(user, msg.chatData));
                }
            }
            else
            {
                Debug.LogError("[Error] Invalid chat user " + conn.connectionId);
            }
        }
Exemple #2
0
        // -------------------------------------------------------------------------------
        // ClientChatSend
        // -------------------------------------------------------------------------------
        public void ClientChatSend(string channelId, string message)
        {
            if (clientChatUser == null || string.IsNullOrEmpty(message))
            {
                Debug.LogWarning("[Warning] Did not login to server can not send chat message");
                return;
            }

            // -- Profanity Filter (applied client side already)
            message = profanityFilter.FilterText(message);

            ChatChannelData channel = null;

            if (Channels.TryGetValue(channelId, out channel))
            {
                string[] chatData = channel.GetChatData(message);
                if (chatData != null && chatData.Length > 0)
                {
                    NetworkConnection     conn        = NetworkClient.connection;
                    MsgChatSendFromClient chatSendMsg = new MsgChatSendFromClient();
                    chatSendMsg.channelId = channelId;
                    chatSendMsg.chatData  = chatData;
                    conn.Send(chatSendMsg);
                }
                else
                {
                    Debug.LogWarning("[Warning] Invalid chat data");
                }
            }
            else
            {
                Debug.LogWarning("[Warning] Chat channel (" + channelId + ") not found");
            }
        }