internal override void ProcessReply(CallbackMessage message, bool moreComing) { if (message is ResolveCallbackMessage rcm) { IEnumerable <DnssdTxtRecord> records = null; if (rcm.Payload.TxtRecord != null) { var trb = new TxtRecordBuilder(); trb.Parse(rcm.Payload.TxtRecord, 0); records = trb.TxtRecords; } ResolveEvent?.Invoke(Token, new ResolveEventArgs(rcm.Payload.FullName, rcm.Payload.HostName, rcm.Payload.Port, rcm.Payload.InterfaceIndex, records, moreComing)); } }
public void ResolveCallbackMessageSerializationTest() { const string hostName = "RPI.local"; const string fullName = ""; const ushort port = 4567; const string txtRecordString = "mac=12:34:56:78:AA:BB"; var txtRecord = TxtRecordBuilder.ParseString(txtRecordString); var txtRecordBytes = txtRecord.GetBytes(); var sm = new ResolveCallbackMessage(CallbackMessageTestHelper.BaseValues, hostName, fullName, port, txtRecordBytes); var dm = CallbackMessageTestHelper.SerializeDeserializeTest(sm); dm.Payload.HostName.Should().Be(hostName); dm.Payload.FullName.Should().Be(fullName); dm.Payload.Port.Should().Be(port); dm.Payload.TxtRecord.Should().BeEquivalentTo(txtRecordBytes); }
private void HandleOperationEvent(object sender, EventArgs args) { CallbackValues = null; switch (args) { case BrowseEventArgs oeArgs: { CallbackValues = (OperationCallbackType.Browse, oeArgs.EventType, oeArgs.Descriptor.InstanceName, oeArgs.Descriptor.ServiceType, oeArgs.Descriptor.Domain, oeArgs.Descriptor.InterfaceIndex); break; } case RegistrationEventArgs oeArgs: { CallbackValues = (OperationCallbackType.Register, oeArgs.EventType, oeArgs.Descriptor.InstanceName, oeArgs.Descriptor.ServiceType, oeArgs.Descriptor.Domain, oeArgs.Descriptor.InterfaceIndex); break; } case ResolveEventArgs oeArgs: { byte[] trBytes = null; if (oeArgs.TxtRecords != null) { var trb = new TxtRecordBuilder(oeArgs.TxtRecords); trBytes = trb.GetBytes(); } CallbackValues = (OperationCallbackType.Resolve, oeArgs.FullName, oeArgs.HostName, oeArgs.Port, trBytes, oeArgs.InterfaceIndex); break; } case LookupEventArgs oeArgs: { CallbackValues = (OperationCallbackType.Lookup, oeArgs.EventType, oeArgs.HostName, oeArgs.IPAddress, oeArgs.Ttl, oeArgs.InterfaceIndex); break; } } _manualResetEvent.Set(); }
public RegisterMessageTests() { var trb = new TxtRecordBuilder(TxtRecordString); _txtRecordBytes = trb.GetBytes(); }