示例#1
0
        public async Task AddDeviceAsync(IAgentContext agentContext, AddDeviceInfoMessage message)
        {
            var connection = await GetMediatorConnectionAsync(agentContext);

            if (connection != null)
            {
                await messageService.SendAsync(agentContext.Wallet, message, connection);
            }
        }
示例#2
0
        private async Task AddDeviceInfoAsync(IAgentContext agentContext, ConnectionRecord connection, AddDeviceInfoMessage addDeviceInfoMessage)
        {
            var inboxId = connection.GetTag("InboxId");

            if (inboxId == null)
            {
                throw new InvalidOperationException("Inbox was not found. Create an inbox first");
            }

            var deviceRecord = new DeviceInfoRecord
            {
                InboxId      = inboxId,
                DeviceId     = addDeviceInfoMessage.DeviceId,
                DeviceVendor = addDeviceInfoMessage.DeviceVendor
            };
            await recordService.AddAsync(agentContext.Wallet, deviceRecord);
        }
示例#3
0
        private async Task AddDeviceInfoAsync(IAgentContext agentContext, ConnectionRecord connection, AddDeviceInfoMessage addDeviceInfoMessage)
        {
            var inboxId = connection.GetTag("InboxId");

            if (inboxId == null)
            {
                throw new InvalidOperationException("Inbox was not found. Create an inbox first");
            }

            var deviceRecord = new DeviceInfoRecord
            {
                InboxId      = inboxId,
                DeviceId     = addDeviceInfoMessage.DeviceId,
                DeviceVendor = addDeviceInfoMessage.DeviceVendor
            };

            try
            {
                await recordService.AddAsync(agentContext.Wallet, deviceRecord);
            }
            catch (WalletItemAlreadyExistsException)
            {
            }
            catch (Exception e)
            {
                logger.LogError(e, "Unable to register device", addDeviceInfoMessage);
            }
        }