Mono.Zeroconf – Diff between revs 1 and 2

Subversion Repositories:
Rev:
Show entire fileRegard whitespace
Rev 1 Rev 2
Line 56... Line 56...
56 56
57 private void SetupCallbacks() 57 private void SetupCallbacks()
58 { 58 {
59 resolve_reply_handler = new Native.DNSServiceResolveReply(OnResolveReply); 59 resolve_reply_handler = new Native.DNSServiceResolveReply(OnResolveReply);
-   60 query_record_reply_handler = new Native.DNSServiceQueryRecordReply(OnQueryRecordReply);
60 query_record_reply_handler = new Native.DNSServiceQueryRecordReply(OnQueryRecordReply); 61 resolveAction = new Action<bool>(Resolve);
Line -... Line 62...
-   62 }
-   63  
61 } 64 private Action<bool> resolveAction;
62   65  
63 public void Resolve() 66 public void Resolve()
-   67 {
-   68 Resolve(false);
-   69 // If people call this in a ServiceAdded eventhandler (which they genreally do)
-   70 // We need to invoke onto another thread otherwise we block processing any more results.
64 { 71  
Line 65... Line 72...
65 Resolve(false); 72 resolveAction.BeginInvoke(false, null, null);
66 } 73 }
67 74
Line 78... Line 85...
78 InterfaceIndex = 0; 85 InterfaceIndex = 0;
79 } 86 }
Line 80... Line 87...
80 87
81 ServiceRef sd_ref; 88 ServiceRef sd_ref;
82 ServiceError error = Native.DNSServiceResolve(out sd_ref, ServiceFlags.None, 89 ServiceError error = Native.DNSServiceResolve(out sd_ref, ServiceFlags.None,
Line 83... Line 90...
83 InterfaceIndex, Name, RegType, ReplyDomain, resolve_reply_handler, IntPtr.Zero); 90 InterfaceIndex, Encoding.UTF8.GetBytes(Name), RegType, ReplyDomain, resolve_reply_handler, IntPtr.Zero);
84 91
85 if(error != ServiceError.NoError) { 92 if(error != ServiceError.NoError) {
Line 103... Line 110...
103 110
104 sd_ref.Process(); 111 sd_ref.Process();
Line 105... Line 112...
105 } 112 }
106 113
107 private void OnResolveReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, 114 private void OnResolveReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex,
108 ServiceError errorCode, string fullname, string hosttarget, ushort port, ushort txtLen, 115 ServiceError errorCode, IntPtr fullname, string hosttarget, ushort port, ushort txtLen,
109 IntPtr txtRecord, IntPtr contex) 116 IntPtr txtRecord, IntPtr contex)
110 { 117 {
Line 111... Line 118...
111 is_resolved = true; 118 is_resolved = true;
112 resolve_pending = false; 119 resolve_pending = false;
113 120
114 InterfaceIndex = interfaceIndex; 121 InterfaceIndex = interfaceIndex;
-   122 FullName = Native.Utf8toString(fullname);
Line 115... Line 123...
115 FullName = fullname; 123 this.port = (ushort)IPAddress.NetworkToHostOrder((short)port);
Line 116... Line 124...
116 this.port = port; 124 TxtRecord = new TxtRecord(txtLen, txtRecord);
117 TxtRecord = new TxtRecord(txtLen, txtRecord); 125 this.hosttarget = hosttarget;
Line 140... Line 148...
140 throw new ServiceErrorException(error); 148 throw new ServiceErrorException(error);
141 } 149 }
Line 142... Line 150...
142 150
143 sd_ref.Process(); 151 sd_ref.Process();
-   152 }
-   153  
-   154 if (hostentry.AddressList != null)
-   155 {
-   156 ServiceResolvedEventHandler handler = Resolved;
-   157 if (handler != null)
-   158 {
-   159 handler(this, new ServiceResolvedEventArgs(this));
-   160 }
144 } 161 }
Line 145... Line 162...
145 } 162 }
146 163
147 private void OnQueryRecordReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, 164 private void OnQueryRecordReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex,
148 ServiceError errorCode, string fullname, ServiceType rrtype, ServiceClass rrclass, ushort rdlen, 165 ServiceError errorCode, string fullname, ServiceType rrtype, ServiceClass rrclass, ushort rdlen,
149 IntPtr rdata, uint ttl, IntPtr context) 166 IntPtr rdata, uint ttl, IntPtr context)
150 { 167 {
-   168 switch(rrtype) {
151 switch(rrtype) { 169 case ServiceType.A:
Line 152... Line 170...
152 case ServiceType.A: 170 case ServiceType.AAAA:
153 IPAddress address; 171 IPAddress address;
154   172  
Line 196... Line 214...
196 break; 214 break;
197 default: 215 default:
198 break; 216 break;
199 } 217 }
Line -... Line 218...
-   218  
-   219  
-   220 if ((flags & ServiceFlags.MoreComing) != ServiceFlags.MoreComing)
200 221 {
201 sdRef.Deallocate(); 222 sdRef.Deallocate();
-   223 }
Line 202... Line 224...
202 } 224 }
203 225
204 public bool IsResolved { 226 public bool IsResolved {
205 get { return is_resolved; } 227 get { return is_resolved; }