Пример #1
0
        public static void ReadChatMessage(Client client, PacketReader reader)
        {
            ChatMessagePacket cm = new ChatMessagePacket();
            cm.Read(reader);

            if (!reader.Failed)
                Client.HandlePacketChatMessage(client, cm);
        }
Пример #2
0
 private void OnChatMessage(ChatMessagePacket p)
 {
     if (ChatMessage != null) ChatMessage.Invoke(this, new PacketEventArgs<ChatMessagePacket>(p));
 }
Пример #3
0
        public static void HandlePacketChatMessage(Client client, ChatMessagePacket packet)
        {
            string clean = Chat.CleanMessage(packet.Message);

            if (clean.StartsWith("/"))
                client.ExecuteCommand(clean.Substring(1));
            else
                client.ExecuteChat(clean);
        }
Пример #4
0
        /// <summary>
        /// Broadcasts a message to all clients, optionally excluding the sender.
        /// </summary>
        /// <param name="message">The message to be broadcasted.</param>
        /// <param name="excludeClient">The client to excluded; usually the sender.</param>
        public void BroadcastSync(string message, IClient excludeClient = null)
        {
            //Event
            ServerBroadcastEventArgs e = new ServerBroadcastEventArgs(this, message, excludeClient);
            PluginManager.CallEvent(Event.ServerBroadcast, e);
            if (e.EventCanceled) return;
            message = e.Message;
            excludeClient = e.ExcludeClient;
            //End Event

            foreach (Client c in GetAuthenticatedClients())
            {
                if (c != excludeClient)
                {
                    ChatMessagePacket cm = new ChatMessagePacket { Message = message };
                    c.Send_Sync_Packet(cm);
                }
            }

            
        }
Пример #5
0
        /// <summary>
        /// Broadcasts a message to all clients, optionally excluding the sender.
        /// </summary>
        /// <param name="message">The message to be broadcasted.</param>
        /// <param name="excludeClient">The client to excluded; usually the sender.</param>
        public void BroadcastSync(string message, Client excludeClient = null, bool sendToIrc = true)
        {
            //Event
            ServerBroadcastEventArgs e = new ServerBroadcastEventArgs(this, message, excludeClient);
            PluginManager.CallEvent(Event.ServerBroadcast, e);
            if (e.EventCanceled) return;
            message = e.Message;
            excludeClient = e.ExcludeClient;
            //End Event

            foreach (Client c in GetClients())
            {
                if (c != excludeClient)
                {
                    ChatMessagePacket cm = new ChatMessagePacket { Message = message };
                    c.Send_Sync_Packet(cm);
                }
            }

            if (sendToIrc && Irc != null)
            {
                Irc.WriteLine("PRIVMSG {0} :{1}", Settings.Default.IrcChannel, message.Replace('§', '\x3'));
            }
        }
Пример #6
0
 public static void HandlePacketChatMessage(TestClient client, ChatMessagePacket cm)
 {
     // Handle some commands?
 }