/// <summary> Creates a new instance. /// /// </summary> /// <param name="source">the JmDNS instance which originated the event. /// </param> /// <param name="type">the type name of the service. /// </param> /// <param name="name">the instance name of the service. /// </param> /// <param name="info">the service info record, or null if the service could be be resolved. /// </param> public ServiceEvent(mDNS source, string type, string name, ServiceInfo info) : base() { this.source = source; this.type = type; this.name = name; this.info = info; }
public ServiceInfoResolver(mDNS enclosingInstance, ServiceInfo info) { InitBlock(enclosingInstance); this.info = info; info.dns = Enclosing_Instance; Enclosing_Instance.AddListener(info, new DNSQuestion(info.QualifiedName, DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN)); }
public Responder(mDNS enclosingInstance, DNSIncoming in_Renamed, IPAddress addr, int port) { InitBlock(enclosingInstance); this.in_Renamed = in_Renamed; this.addr = addr; this.port = port; }
public Canceler(mDNS enclosingInstance, ServiceInfo info, object lock_Renamed) { InitBlock(enclosingInstance); this.infos = new ServiceInfo[]{info}; this.lock_Renamed = lock_Renamed; Enclosing_Instance.AddListener(info, new DNSQuestion(info.QualifiedName, DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN)); }
/// <summary> Does the necessary actions, when this as a query.</summary> internal override bool HandleQuery(mDNS dns, long expirationTime) { Address dnsAddress = dns.LocalHost.GetDNSAddressRecord(this); if (dnsAddress != null) { if (dnsAddress.SameType(this) && dnsAddress.SameName(this) && (!dnsAddress.SameValue(this))) { logger.Debug("handleQuery() Conflicting probe detected. dns state " + dns.State + " lex compare " + lexCompare(dnsAddress)); // Tie-breaker test if (dns.State.Probing && lexCompare(dnsAddress) >= 0) { // We lost the tie-break. We have to choose a different name. dns.LocalHost.IncrementHostName(); dns.Cache.clear(); foreach (ServiceInfo info in dns.services) { info.RevertState(); } } dns.RevertState(); return(true); } } return(false); }
/// <summary> Does the necessary actions, when this as a response.</summary> internal override bool HandleResponse(mDNS dns) { Address dnsAddress = dns.LocalHost.GetDNSAddressRecord(this); if (dnsAddress != null) { if (dnsAddress.SameType(this) && dnsAddress.SameName(this) && (!dnsAddress.SameValue(this))) { logger.Debug("handleResponse() Denial detected"); if (dns.State.Probing) { dns.LocalHost.IncrementHostName(); dns.Cache.clear(); foreach (ServiceInfo info in dns.services) { info.RevertState(); } } dns.RevertState(); return(true); } } return(false); }
public Canceler(mDNS enclosingInstance, ServiceInfo info, object lock_Renamed) { InitBlock(enclosingInstance); this.infos = new ServiceInfo[] { info }; this.lock_Renamed = lock_Renamed; Enclosing_Instance.AddListener(info, new DNSQuestion(info.QualifiedName, DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN)); }
// REMIND: Oops, this shouldn't be public! /// <summary> JmDNS callback to update a DNS record.</summary> public virtual void UpdateRecord(mDNS jmdns, long now, DNSRecord rec) { if ((rec != null) && !rec.IsExpired(now)) { switch (rec.type) { case DNSConstants.TYPE_A: // IPv4 case DNSConstants.TYPE_AAAA: // IPv6 FIXME [PJYF Oct 14 2004] This has not been tested if (rec.name.Equals(server)) { addr = ((Address)rec).IPAddress; } break; case DNSConstants.TYPE_SRV: if (rec.name.Equals(QualifiedName)) { Service srv = (Service)rec; server = srv.server; port = srv.port; weight = srv.weight; priority = srv.priority; addr = null; // changed to use getCache() instead - jeffs // updateRecord(jmdns, now, (DNSRecord)jmdns.cache.get(server, TYPE_A, CLASS_IN)); UpdateRecord(jmdns, now, (DNSRecord)jmdns.Cache.get_Renamed(server, DNSConstants.TYPE_A, DNSConstants.CLASS_IN)); } break; case DNSConstants.TYPE_TXT: if (rec.name.Equals(QualifiedName)) { Text txt = (Text)rec; text = txt.text; } break; } // Future Design Pattern // This is done, to notify the wait loop in method // JmDNS.getServiceInfo(type, name, timeout); if (HasData && dns != null) { dns.HandleServiceResolved(this); dns = null; } lock (this) { Monitor.PulseAll(this); } } }
internal override DNSOutgoing AddAnswer(mDNS dns, DNSIncoming in_Renamed, IPAddress addr, int port, DNSOutgoing out_Renamed) { ServiceInfo info = (ServiceInfo)dns.services[name.ToLower()]; if (info != null) { if (this.port == info.port != server.Equals(dns.LocalHost.Name)) { return(dns.AddAnswer(in_Renamed, addr, port, out_Renamed, new Service(info.QualifiedName, DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, DNSConstants.DNS_TTL, info.priority, info.weight, info.port, dns.LocalHost.Name))); } } return(out_Renamed); }
internal override bool HandleResponse(mDNS dns) { // Nothing to do (?) // Shouldn't we care if we get a conflict at this level? /* ServiceInfo info = (ServiceInfo) dns.services.get(name.toLowerCase()); if (info != null) { if (! Arrays.equals(text,info.text)) { info.revertState(); return true; } }*/ return false; }
internal override bool HandleResponse(mDNS dns) { // Nothing to do (?) // Shouldn't we care if we get a conflict at this level? /* * ServiceInfo info = (ServiceInfo) dns.services.get(name.toLowerCase()); * if (info != null) { * if (! Arrays.equals(text,info.text)) { * info.revertState(); * return true; * } * }*/ return(false); }
public Renewer(mDNS enclosingInstance) { InitBlock(enclosingInstance); // Associate host to this, if it needs renewal if (Enclosing_Instance.State == DNSState.ANNOUNCED) { Enclosing_Instance.Task = this; } // Associate services to this, if they need renewal lock (Enclosing_Instance) { foreach (ServiceInfo info in Enclosing_Instance.services.Values) { if (info.State == DNSState.ANNOUNCED) { info.task = this; } } } }
public Prober(mDNS enclosingInstance) { InitBlock(enclosingInstance); // Associate the host name to this, if it needs probing if (Enclosing_Instance.State == DNSState.PROBING_1) { Enclosing_Instance.Task = this; } // Associate services to this, if they need probing lock (Enclosing_Instance) { foreach (ServiceInfo info in Enclosing_Instance.services.Values) { if (info.State == DNSState.PROBING_1) { info.task = this; } } } }
public Announcer(mDNS enclosingInstance) { InitBlock(enclosingInstance); // Associate host to this, if it needs announcing if (Enclosing_Instance.State == DNSState.ANNOUNCING_1) { Enclosing_Instance.Task = this; } // Associate services to this, if they need announcing lock (Enclosing_Instance) { foreach (ServiceInfo info in Enclosing_Instance.services.Values) { if (info.State == DNSState.ANNOUNCING_1) { info.task = this; } } } }
internal override bool HandleResponse(mDNS dns) { ServiceInfo info = (ServiceInfo)dns.services[name.ToLower()]; if (info != null && (port != info.port || !server.ToUpper().Equals(dns.LocalHost.Name.ToUpper()))) { logger.Debug("handleResponse() Denial detected"); if (info.State.Probing) { string oldName = info.QualifiedName.ToLower(); info.SetName(dns.IncrementName(info.getName())); dns.services.Remove(oldName); dns.services[info.QualifiedName.ToLower()] = info; logger.Debug("handleResponse() New unique name chose:" + info.getName()); } info.RevertState(); return(true); } return(false); }
internal override bool HandleQuery(mDNS dns, long expirationTime) { ServiceInfo info = (ServiceInfo)dns.services[name.ToLower()]; if (info != null && (port != info.port || !server.ToUpper().Equals(dns.LocalHost.Name.ToUpper()))) { logger.Debug("handleQuery() Conflicting probe detected"); // Tie breaker test if (info.State.Probing && lexCompare(new Service(info.QualifiedName, DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, DNSConstants.DNS_TTL, info.priority, info.weight, info.port, dns.LocalHost.Name)) >= 0) { // We lost the tie break string oldName = info.QualifiedName.ToLower(); info.SetName(dns.IncrementName(info.getName())); dns.services.Remove(oldName); dns.services[info.QualifiedName.ToLower()] = info; logger.Debug("handleQuery() Lost tie break: new unique name chosen:" + info.getName()); } info.RevertState(); return(true); } return(false); }
// Use this for initialization async void Start() { #if !UNITY_EDITOR // broadcast a service over mDNS / Bonjour / Zeroconfig to avoid having to enter an IP addres // arguably this should be the client and the camera should be the server, but I couldn't get it to work that way around for some reason LoggingManager.Log("Starting Bonjour"); mDNS.Logging.LogManager.MessageReceived += LogManager_MessageReceived; var service = new mDNS.mDNS(false); await service.Init(); LoggingManager.Log("Initialized Bonjour, broadcasting service"); service.RegisterService(new mDNS.ServiceInfo("_hololens3._tcp.local.", SystemInfo.deviceName, broadcastPort, "HELLO")); // establish command connection commandSocket = new StreamSocketListener(); commandSocket.ConnectionReceived += Server_ConnectionReceived; await commandSocket.BindServiceNameAsync(commandPort.ToString()); // establish video connection videoSocket = new StreamSocketListener(); videoSocket.ConnectionReceived += Server_ConnectionReceived; await videoSocket.BindServiceNameAsync(videoPort.ToString()); #endif }
private void InitBlock(mDNS enclosingInstance) { this.enclosingInstance = enclosingInstance; }
/// <summary> Creates a new instance. /// /// </summary> /// <param name="source">the JmDNS instance which originated the event. /// </param> /// <param name="type">the type name of the service. /// </param> /// <param name="name">the instance name of the service. /// </param> /// <param name="info">the service info record, or null if the service could be be resolved. /// </param> public ServiceEvent(mDNS source, string type, string name, ServiceInfo info):base() { this.source = source; this.type = type; this.name = name; this.info = info; }
internal override DNSOutgoing AddAnswer(mDNS dns, DNSIncoming in_Renamed, IPAddress addr, int port, DNSOutgoing out_Renamed) { return out_Renamed; }
/// <summary> Does the necessary actions, when this as a query.</summary> internal override bool HandleQuery(mDNS dns, long expirationTime) { Address dnsAddress = dns.LocalHost.GetDNSAddressRecord(this); if (dnsAddress != null) { if (dnsAddress.SameType(this) && dnsAddress.SameName(this) && (!dnsAddress.SameValue(this))) { logger.Debug("handleQuery() Conflicting probe detected. dns state " + dns.State + " lex compare " + lexCompare(dnsAddress)); // Tie-breaker test if (dns.State.Probing && lexCompare(dnsAddress) >= 0) { // We lost the tie-break. We have to choose a different name. dns.LocalHost.IncrementHostName(); dns.Cache.clear(); foreach (ServiceInfo info in dns.services) { info.RevertState(); } } dns.RevertState(); return true; } } return false; }
public ServiceResolver(mDNS enclosingInstance, string type) { InitBlock(enclosingInstance); this.type = type; }
internal override bool HandleQuery(mDNS dns, long expirationTime) { ServiceInfo info = (ServiceInfo) dns.services[name.ToLower()]; if (info != null && (port != info.port || !server.ToUpper().Equals(dns.LocalHost.Name.ToUpper()))) { logger.Debug("handleQuery() Conflicting probe detected"); // Tie breaker test if (info.State.Probing && lexCompare(new Service(info.QualifiedName, DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, DNSConstants.DNS_TTL, info.priority, info.weight, info.port, dns.LocalHost.Name)) >= 0) { // We lost the tie break string oldName = info.QualifiedName.ToLower(); info.SetName(dns.IncrementName(info.getName())); dns.services.Remove(oldName); dns.services[info.QualifiedName.ToLower()] = info; logger.Debug("handleQuery() Lost tie break: new unique name chosen:" + info.getName()); } info.RevertState(); return true; } return false; }
private void InitBlock(mDNS enclosingInstance) { this.enclosingInstance = enclosingInstance; taskState = DNSState.ANNOUNCING_1; }
/// <summary> Adds this as an answer to the provided outgoing datagram.</summary> internal abstract DNSOutgoing AddAnswer(mDNS dns, DNSIncoming in_Renamed, IPAddress addr, int port, DNSOutgoing out_Renamed);
internal override bool HandleResponse(mDNS dns) { // Nothing to do (?) // I think there is no possibility for conflicts for this record type? return(false); }
public RecordReaper(mDNS enclosingInstance) { InitBlock(enclosingInstance); }
internal override bool HandleResponse(mDNS dns) { ServiceInfo info = (ServiceInfo) dns.services[name.ToLower()]; if (info != null && (port != info.port || !server.ToUpper().Equals(dns.LocalHost.Name.ToUpper()))) { logger.Debug("handleResponse() Denial detected"); if (info.State.Probing) { string oldName = info.QualifiedName.ToLower(); info.SetName(dns.IncrementName(info.getName())); dns.services.Remove(oldName); dns.services[info.QualifiedName.ToLower()] = info; logger.Debug("handleResponse() New unique name chose:" + info.getName()); } info.RevertState(); return true; } return false; }
internal override bool HandleResponse(mDNS dns) { // Nothing to do (?) // I think there is no possibility for conflicts for this record type? return false; }
internal override bool HandleQuery(mDNS dns, long expirationTime) { // Nothing to do (?) // I think there is no possibility for conflicts for this record type? return false; }
/// <summary> Handles a responserepresented by this record. /// /// </summary> /// <returns> Returns true if a conflict with one of the services registered /// with JmDNS or with the hostname occured. /// </returns> internal abstract bool HandleResponse(mDNS dns);
/// <summary> Handles a query represented by this record. /// /// </summary> /// <returns> Returns true if a conflict with one of the services registered /// with JmDNS or with the hostname occured. /// </returns> internal abstract bool HandleQuery(mDNS dns, long expirationTime);
public Canceler(mDNS enclosingInstance, ICollection infos, object lock_Renamed) { InitBlock(enclosingInstance); this.infos = (ServiceInfo[]) SupportClass.ICollectionSupport.ToArray(infos, new ServiceInfo[infos.Count]); this.lock_Renamed = lock_Renamed; }
public TypeResolver(mDNS enclosingInstance) { InitBlock(enclosingInstance); }
public Shutdown(mDNS enclosingInstance) { InitBlock(enclosingInstance); }
/// <summary> Does the necessary actions, when this as a response.</summary> internal override bool HandleResponse(mDNS dns) { Address dnsAddress = dns.LocalHost.GetDNSAddressRecord(this); if (dnsAddress != null) { if (dnsAddress.SameType(this) && dnsAddress.SameName(this) && (!dnsAddress.SameValue(this))) { logger.Debug("handleResponse() Denial detected"); if (dns.State.Probing) { dns.LocalHost.IncrementHostName(); dns.Cache.clear(); foreach (ServiceInfo info in dns.services) { info.RevertState(); } } dns.RevertState(); return true; } } return false; }
// REMIND: Oops, this shouldn't be public! /// <summary> JmDNS callback to update a DNS record.</summary> public virtual void UpdateRecord(mDNS jmdns, long now, DNSRecord rec) { if ((rec != null) && !rec.IsExpired(now)) { switch (rec.type) { case DNSConstants.TYPE_A: // IPv4 case DNSConstants.TYPE_AAAA: // IPv6 FIXME [PJYF Oct 14 2004] This has not been tested if (rec.name.Equals(server)) { addr = ((Address) rec).IPAddress; } break; case DNSConstants.TYPE_SRV: if (rec.name.Equals(QualifiedName)) { Service srv = (Service) rec; server = srv.server; port = srv.port; weight = srv.weight; priority = srv.priority; addr = null; // changed to use getCache() instead - jeffs // updateRecord(jmdns, now, (DNSRecord)jmdns.cache.get(server, TYPE_A, CLASS_IN)); UpdateRecord(jmdns, now, (DNSRecord) jmdns.Cache.get_Renamed(server, DNSConstants.TYPE_A, DNSConstants.CLASS_IN)); } break; case DNSConstants.TYPE_TXT: if (rec.name.Equals(QualifiedName)) { Text txt = (Text) rec; text = txt.text; } break; } // Future Design Pattern // This is done, to notify the wait loop in method // JmDNS.getServiceInfo(type, name, timeout); if (HasData && dns != null) { dns.HandleServiceResolved(this); dns = null; } lock (this) { Monitor.PulseAll(this); } } }
public SocketListener(mDNS enclosingInstance) { InitBlock(enclosingInstance); }
private void InitBlock(mDNS enclosingInstance) { this.enclosingInstance = enclosingInstance; taskState = DNSState.PROBING_1; }
internal override bool HandleQuery(mDNS dns, long expirationTime) { // Nothing to do (?) // I think there is no possibility for conflicts for this record type? return(false); }
private void InitBlock(mDNS enclosingInstance) { this.enclosingInstance = enclosingInstance; taskState = DNSState.ANNOUNCED; }
internal override DNSOutgoing AddAnswer(mDNS dns, DNSIncoming in_Renamed, IPAddress addr, int port, DNSOutgoing out_Renamed) { return(out_Renamed); }
public Canceler(mDNS enclosingInstance, ICollection infos, object lock_Renamed) { InitBlock(enclosingInstance); this.infos = (ServiceInfo[])SupportClass.ICollectionSupport.ToArray(infos, new ServiceInfo[infos.Count]); this.lock_Renamed = lock_Renamed; }
public Canceler(mDNS enclosingInstance, ServiceInfo[] infos, object lock_Renamed) { InitBlock(enclosingInstance); this.infos = infos; this.lock_Renamed = lock_Renamed; }
internal override DNSOutgoing AddAnswer(mDNS dns, DNSIncoming in_Renamed, IPAddress addr, int port, DNSOutgoing out_Renamed) { ServiceInfo info = (ServiceInfo) dns.services[name.ToLower()]; if (info != null) { if (this.port == info.port != server.Equals(dns.LocalHost.Name)) { return dns.AddAnswer(in_Renamed, addr, port, out_Renamed, new Service(info.QualifiedName, DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, DNSConstants.DNS_TTL, info.priority, info.weight, info.port, dns.LocalHost.Name)); } } return out_Renamed; }