Ejemplo n.º 1
0
 public void BroadCast(Message msg) {
     ChatroomServer server = ChatroomServer.GetSingleton();
     MessageListener[] listeners = server.GetClients();
     foreach (MessageListener listener in listeners) {
         /// a oneway call, no answer!
         listener.NotifyMessage(msg);
     }
 }
        public void NotifyMessage(Message msg) {
            // m_view.AddMessage(msg);
            // works only when the message was sent asynchronously

            // because we are in a different thread from the thread created the form, we need to invoke the update method in
            // in the following way:
            Chatform.UpdateInvoker invoker = new Chatform.UpdateInvoker(m_view.AddMessage);
            // need an async call here, because click on button blocks windows, call to update can only succeed after click handling
            // has finished
            m_view.BeginInvoke(invoker, new object[] { msg });
        }