//private void DataReceived(object o)
private void DataSocket_MessageReceived(Windows.Networking.Sockets.DatagramSocket sender, Windows.Networking.Sockets.DatagramSocketMessageReceivedEventArgs args)
{
try
{
var reader = args.GetDataReader();
byte[] data = new byte[reader.UnconsumedBufferLength];
args.GetDataReader().ReadBytes(data);
this.socket = sender;
var dhcpRequest = new DHCPRequest(data, socket, this);
//ccDHCP = new clsDHCP();
//data is now in the structure
//get the msg type
OnDataReceived(this, dhcpRequest);
var msgType = dhcpRequest.GetMsgType();
switch (msgType)
{
case DHCPMsgType.DHCPDISCOVER:
OnDiscover(this, dhcpRequest);
break;
case DHCPMsgType.DHCPREQUEST:
OnRequest(this, dhcpRequest);
break;
case DHCPMsgType.DHCPDECLINE:
OnDecline(this, dhcpRequest);
break;
case DHCPMsgType.DHCPRELEASE:
OnReleased(this, dhcpRequest);
break;
case DHCPMsgType.DHCPINFORM:
OnInform(this, dhcpRequest);
break;
//default:
// Console.WriteLine("Unknown DHCP message: " + (int)MsgTyp + " (" + MsgTyp.ToString() + ")");
// break;
}
}
catch (Exception ex)
{
if (UnhandledException != null)
{
UnhandledException(this, ex);
}
}
}