Exemplo n.º 1
0
        //This is called when a message is received (before any events are called)
        private void OnBroadcastMessage(IAsyncResult res)
        {
            byte[] received = client.EndReceive(res, ref remoteEP);

            // Begin receiving A$AP
            client.BeginReceive(new AsyncCallback(OnBroadcastMessage), null);

            //Process the message
            if (!remoteEP.Address.Equals(localEP.Address)) // message is from someone else
            {
                NewBroadcastEventArgs args = new NewBroadcastEventArgs();
                args.message = Encoding.ASCII.GetString(received);

                // raise events
                Message(this, args);
            }
        }
Exemplo n.º 2
0
 private static void Broadcast_Message(object sender, NewBroadcastEventArgs e)
 {
     Console.WriteLine("New Message: " + e.message);
 }
Exemplo n.º 3
0
        // EventThing
        protected virtual void OnMessage(NewBroadcastEventArgs e)
        {
            EventHandler <NewBroadcastEventArgs> handler = Message;

            handler?.Invoke(this, e);
        }