public void ProcessReceive(byte[] buf)
    {
        var msg = Parse(buf);



        //do dispatch
        m_MessageDispatcher.Dispatcher(this, msg.GetType().ToString(), (IMessage)msg);
    }
Example #2
0
    // Use this for initialization
    public void Start()
    {
        Task.Factory.StartNew(() =>
        {
            m_Client = new UdpClient(28888);

            while (true)
            {
                var groupEP = new IPEndPoint(IPAddress.Any, 28888); // listen on any port
                var data    = m_Client.Receive(ref groupEP);



                var msg = MessageSerializer.Parse(data);
                if (m_Dispatcher != null)
                {
                    m_Dispatcher.Dispatcher(null, msg.GetType().ToString(), (IMessage)msg);
                }

                //udpServer.Send(new byte[] { 1 }, 1); // if data is received reply letting the client know that we got his data
            }
        });
    }