Exemple #1
0
 internal override void ProcessReply(CallbackMessage message, bool moreComing)
 {
     if (message is RegisterCallbackMessage rcm)
     {
         var error      = rcm.Payload.Error;
         var descriptor = new ServiceDescriptor(rcm.Payload.InstanceName, rcm.Payload.ServiceType, rcm.Payload.Domain, rcm.Payload.InterfaceIndex);
         var type       = error == ServiceError.NoError ?
                          rcm.Payload.Flags.HasFlag(ServiceFlags.Add) ? RegistrationEventType.Added : RegistrationEventType.Removed :
                          RegistrationEventType.Error;
         RegistrationEvent?.Invoke(Token, new RegistrationEventArgs(type, descriptor, error, moreComing));
     }
 }
        public async Task <IOperationToken> RegisterAsync(string instanceName, string serviceType, string domain, string host, ushort port, byte[] txtRecord, uint interfaceIndex = 0, object context = null)
        {
            await CheckConnectionAsync();

            var op = new RegisterOperation(instanceName, serviceType, domain, host, port, txtRecord, interfaceIndex, context);

            op.RegistrationEvent += (s, e) => RegistrationEvent?.Invoke(s, e);

            await _connection.AddAndExecuteSubordinate(op);

            return(op.Token);
        }