コード例 #1
0
ファイル: Broadcast.cs プロジェクト: iiKurt/PolarBear
        //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 = new RemoteMessage(received);

                switch (args.message.Event)
                {
                case Event.Join:
                    OnJoin(args);
                    break;

                case Event.Discovery:
                    OnDiscovery(args);
                    break;

                case Event.Leave:
                    OnLeave(args);
                    break;

                case Event.Message:
                    OnMessage(args);
                    break;
                }
            }
        }
コード例 #2
0
 public void OnBroadcastLeave(object sender, NewBroadcastEventArgs e) =>
 Dispatcher.BeginInvoke(new Action(() =>
                                   Broadcast_Leave(new RemoteClient(e.message.Contents))
                                   ));
コード例 #3
0
 public void OnBroadcastMessage(object sender, NewBroadcastEventArgs e) =>
 Dispatcher.BeginInvoke(new Action(() =>
                                   Broadcast_Message(e.message)
                                   ));
コード例 #4
0
ファイル: Broadcast.cs プロジェクト: iiKurt/PolarBear
        protected virtual void OnMessage(NewBroadcastEventArgs e)
        {
            EventHandler <NewBroadcastEventArgs> handler = Message;

            handler?.Invoke(this, e);
        }
コード例 #5
0
ファイル: Broadcast.cs プロジェクト: iiKurt/PolarBear
        protected virtual void OnDiscovery(NewBroadcastEventArgs e)
        {
            EventHandler <NewBroadcastEventArgs> handler = Discovery;

            handler?.Invoke(this, e);
        }
コード例 #6
0
ファイル: Broadcast.cs プロジェクト: iiKurt/PolarBear
        // EventThing
        protected virtual void OnJoin(NewBroadcastEventArgs e)
        {
            EventHandler <NewBroadcastEventArgs> handler = Join;

            handler?.Invoke(this, e);
        }