internal override bool OnAsyncResultReceived(AsyncReceiveBuffer result) { try { var dgram = HttpDatagram.Parse(result.Buffer); if (dgram == null || dgram.Type != HttpDatagramType.MSearch) { return(true); } var st = dgram.Headers.Get("ST"); var mx = dgram.Headers.Get("MX"); var man = dgram.Headers.Get("Man"); if (string.IsNullOrEmpty(st) || string.IsNullOrEmpty(mx) || man != Protocol.SsdpDiscoverMan) { return(true); } server.RequestRecieved(new Request(result.SenderIPEndPoint, st, UInt16.Parse(mx))); } catch (Exception e) { Log.Exception("Invalid HTTPMU/M-SEARCH datagram", e); } return(true); }
void AsyncReadResult (AsyncReceiveBuffer buffer) { try { buffer.Socket.BeginReceiveFrom (buffer, OnAsyncResultReceived); } catch (ObjectDisposedException) { // Socket disposed while we were receiving from it... just ignore this } }
internal override bool OnAsyncResultReceived(AsyncReceiveBuffer result) { try { HttpDatagram dgram = HttpDatagram.Parse(result.Buffer); if (dgram == null || dgram.Type != HttpDatagramType.Notify) { return(true); } string nts = dgram.Headers.Get("NTS"); string usn = dgram.Headers.Get("USN"); string nt = dgram.Headers.Get("NT"); if (String.IsNullOrEmpty(nts) || String.IsNullOrEmpty(usn)) { return(true); } if (!client.ServiceTypeRegistered(nt)) { return(true); } if (nts == Protocol.SsdpAliveNts) { try { if (!client.ServiceCache.Update(usn, dgram)) { client.ServiceCache.Add(new BrowseService(dgram, true)); } } catch (Exception e) { Log.Exception("Invalid ssdp:alive NOTIFY", e); } } else if (nts == Protocol.SsdpByeByeNts) { client.ServiceCache.Remove(usn); } } catch (Exception e) { Log.Exception("Invalid HTTPMU/NOTIFY datagram", e); } return(true); }
internal override bool OnAsyncResultReceived (AsyncReceiveBuffer result) { try { var dgram = HttpDatagram.Parse (result.Buffer); if (dgram == null || dgram.Type != HttpDatagramType.MSearch) { return true; } var st = dgram.Headers.Get ("ST"); var mx = dgram.Headers.Get ("MX"); var man = dgram.Headers.Get ("Man"); if (string.IsNullOrEmpty (st) || string.IsNullOrEmpty (mx) || man != Protocol.SsdpDiscoverMan) { return true; } server.RequestRecieved (new Request (result.SenderIPEndPoint, st, UInt16.Parse(mx))); } catch (Exception e) { Log.Exception ("Invalid HTTPMU/M-SEARCH datagram", e); } return true; }
internal override bool OnAsyncResultReceived(AsyncReceiveBuffer result) { try { HttpDatagram dgram = HttpDatagram.Parse (result.Buffer); if (dgram == null || dgram.Type != HttpDatagramType.Notify) { return true; } string nts = dgram.Headers.Get ("NTS"); string usn = dgram.Headers.Get ("USN"); string nt = dgram.Headers.Get ("NT"); if (String.IsNullOrEmpty (nts) || String.IsNullOrEmpty (usn)) { return true; } if (!client.ServiceTypeRegistered (nt)) { return true; } if (nts == Protocol.SsdpAliveNts) { try { if (!client.ServiceCache.Update (usn, dgram)) { client.ServiceCache.Add (new BrowseService (dgram, true)); } } catch (Exception e) { Log.Exception ("Invalid ssdp:alive NOTIFY", e); } } else if (nts == Protocol.SsdpByeByeNts) { client.ServiceCache.Remove (usn); } } catch (Exception e) { Log.Exception ("Invalid HTTPMU/NOTIFY datagram", e); } return true; }
private void AsyncReadResult(AsyncReceiveBuffer buffer) { buffer.Socket.BeginReceiveFrom (buffer, OnAsyncResultReceived); }
internal virtual bool OnAsyncResultReceived(AsyncReceiveBuffer result) { return false; }
public IAsyncResult BeginReceiveFrom(AsyncReceiveBuffer buffer, AsyncCallback callback) { return(base.BeginReceiveFrom(buffer.Buffer, 0, buffer.Buffer.Length, SocketFlags.None, ref buffer.SenderEndPoint, callback, buffer)); }
public IAsyncResult BeginReceiveFrom(AsyncReceiveBuffer buffer, AsyncCallback callback) { return base.BeginReceiveFrom (buffer.Buffer, 0, buffer.Buffer.Length, SocketFlags.None, ref buffer.SenderEndPoint, callback, buffer); }
internal override bool OnAsyncResultReceived (AsyncReceiveBuffer result) { try { HttpDatagram dgram = HttpDatagram.Parse (result.Buffer); if (dgram == null) { return true; } try { client.ServiceCache.Add (new BrowseService (dgram, false)); } catch (Exception e) { Log.Exception ("Invalid browse response", e); } } catch (Exception e) { Log.Exception ("Invalid HTTPU datagram", e); } return true; }