public async Task OnPostSendMessageAsync(string connectionId, string text) { var context = new DefaultAgentContext { Wallet = await _walletService.GetWalletAsync(_walletOptions.WalletConfiguration, _walletOptions.WalletCredentials) }; var sentTime = DateTime.UtcNow; var messageRecord = new BasicMessageRecord { Id = Guid.NewGuid().ToString(), Direction = MessageDirection.Outgoing, Text = text, SentTime = sentTime, ConnectionId = connectionId }; var message = new BasicMessage { Content = text, SentTime = sentTime.ToString("s", CultureInfo.InvariantCulture) }; var connection = await _connectionService.GetAsync(context, connectionId); // Save the outgoing message to the local wallet for chat history purposes await _recordService.AddAsync(context.Wallet, messageRecord); // Send an agent message using the secure connection await _messageService.SendAsync(context.Wallet, message, connection); }
public async Task OnGetAsync(string id, bool?trustPingSuccess = null) { var context = new DefaultAgentContext { Wallet = await _walletService.GetWalletAsync(_walletOptions.WalletConfiguration, _walletOptions.WalletCredentials) }; Connection = await _connectionService.GetAsync(context, id); Messages = await _recordService.SearchAsync <BasicMessageRecord>(context.Wallet, SearchQuery.Equal(nameof(BasicMessageRecord.ConnectionId), id), null, 10); TrustPingSuccess = trustPingSuccess; }
public async Task <IActionResult> Details(string id, bool?trustPingSuccess = null) { var context = new DefaultAgentContext { Wallet = await _walletService.GetWalletAsync(_walletOptions.WalletConfiguration, _walletOptions.WalletCredentials) }; var model = new ConnectionDetailsViewModel { Connection = await _connectionService.GetAsync(context, id), Messages = await _recordService.SearchAsync <BasicMessageRecord>(context.Wallet, SearchQuery.Equal(nameof(BasicMessageRecord.ConnectionId), id), null, 10), TrustPingSuccess = trustPingSuccess }; return(View(model)); }
public async Task <SendMessageResponse> Handle ( SendMessageRequest aSendMessageRequest, CancellationToken aCancellationToken ) { var defaultAgentContext = new DefaultAgentContext { Wallet = await WalletService.GetWalletAsync(AgentOptions.WalletConfiguration, AgentOptions.WalletCredentials) }; DateTime sentTime = DateTime.UtcNow; var messageRecord = new BasicMessageRecord { Id = Guid.NewGuid().ToString(), Direction = MessageDirection.Outgoing, Text = aSendMessageRequest.Message, SentTime = sentTime, ConnectionId = aSendMessageRequest.ConnectionId }; var basicMessage = new BasicMessage(defaultAgentContext.UseMessageTypesHttps) { Content = aSendMessageRequest.Message, SentTime = sentTime.ToString("s", CultureInfo.InvariantCulture) }; ConnectionRecord connectionRecord = await ConnectionService.GetAsync(defaultAgentContext, aSendMessageRequest.ConnectionId); // Save the outgoing message to the local wallet for chat history purposes await WalletRecordService.AddAsync(defaultAgentContext.Wallet, messageRecord); // Send an agent message using the secure connection await MessageService.SendAsync(defaultAgentContext, basicMessage, connectionRecord); var response = new SendMessageResponse(aSendMessageRequest.CorrelationId); return(response); }
public async Task <IAgentContext> GetContextAsync(params object[] args) { var configurationName = Preferences.Get(Constants.PoolConfigurationName, "sovrin-staging"); try { var agentContext = new DefaultAgentContext { SupportedMessages = _agent.GetSupportedMessageTypes(), Wallet = await _walletService.GetWalletAsync( configuration : new WalletConfiguration { Id = Constants.LocalWalletIdKey, StorageConfiguration = new WalletConfiguration.WalletStorageConfiguration { Path = Path.Combine( FileSystem.AppDataDirectory, ".indy_client", "wallets") } }, credentials : new WalletCredentials { Key = await SyncedSecureStorage.GetAsync(Constants.LocalWalletCredentialKey) }), Pool = new PoolAwaitable(async() => await _poolService.GetPoolAsync(configurationName, 2)), Agent = _agent }; return(agentContext); } catch (Exception e) { Debug.WriteLine(e.Message); return(null); } }