Esempio n. 1
0
 private async Task Send(ServerDetail data)
 {
     var client     = new UdpClient();
     var dataString = data.Serialize();
     var bytes      = Encoding.ASCII.GetBytes(dataString);
     await client.SendAsync(bytes, bytes.Length, SendEndpoint);
 }
Esempio n. 2
0
        private async Task <ServerDetail> Receive()
        {
            var client    = new UdpClient(ListenEndpoint);
            var asyncData = await client.ReceiveAsync();

            var data = Encoding.ASCII.GetString(asyncData.Buffer);

            try
            {
                return(ServerDetail.Unserialize(data));
            }
            catch (FormatException)
            {
                return(null);
            }
        }
Esempio n. 3
0
        public Timer StartBroadcast(ServerDetail detail)
        {
            var timer = new Timer(this.SendTimer, detail, 0, BroadcastDelay);

            return(timer);
        }