Beispiel #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);
 }
Beispiel #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);
            }
        }
Beispiel #3
0
        public Timer StartBroadcast(ServerDetail detail)
        {
            var timer = new Timer(this.SendTimer, detail, 0, BroadcastDelay);

            return(timer);
        }