示例#1
0
文件: Server.cs 项目: IdentErr/c-raft
        /// <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'));
            }
        }
示例#2
0
 private void OnBroadcast(ServerBroadcastEventArgs e)
 {
     foreach (EventListener el in Plugins)
     {
         ServerListener sl = (ServerListener)el.Listener;
         if (el.Event == Event.ServerBroadcast)
             sl.OnBroadcast(e);
     }
 }
示例#3
0
文件: Server.cs 项目: dekema2/c-raft
        /// <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 Broadcast(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 GetAuthenticatedClients())
            {
                if (c != excludeClient)
                    c.SendMessage(message);
            }

            if (sendToIrc && Irc != null)
            {
                Irc.WriteLine("PRIVMSG {0} :{1}", ChraftConfig.IrcChannel, message.Replace('§', '\x3'));
            }
        }
示例#4
0
 public virtual void OnBroadcast(ServerBroadcastEventArgs e)
 {
 }