protected override async void Decode(IChannelHandlerContext context, IByteBuffer input, List <object> output) { try { tenancyContext = context.GetAttribute <AbstractTenancyContext>(AttributeKey <AbstractTenancyContext> .ValueOf(AbstractTenancyContext.TENANCY_CONTEXT_KEY)).Get(); var dataPacket = await tenancyContext?.Decode(input); dataPacket.EventTopicAddress = GetDeviceD2CAddress(dataPacket.DeviceId); var connectPacket = await GetDeviceCredentialAsync(tenancyContext.TenantId, dataPacket.DeviceId); output.Add(new Dictionary <PacketType, Packet>() { { PacketType.CONNECT, connectPacket }, { PacketType.D2C, dataPacket } }); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } }
/// <summary> /// Use tenant identifier and create the appropriate context object /// </summary> private bool EstablishTenancyContext(string tenantId, string tenantName, X509Chain chain) { this.tenantContext = TenancyContextFactory.GetContext(tenantName, tenantId, chain, this.capturedContext, this.settingsProvider); return(true); }
/// <summary> /// Use tenant identifier and create the appropriate context object /// </summary> private void SetupDelayedTenancyIdentifier() { this.tenantContext = TenancyContextFactory.GetContext(null, null, null, this.capturedContext, this.settingsProvider); }