-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into upgrade-afj-0-4-0
- Loading branch information
Showing
5 changed files
with
35 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 11 additions & 10 deletions
21
packages/transport-ble/src/transports/BleTransportSession.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
import type { Central } from '@animo-id/react-native-ble-didcomm' | ||
import type { Agent, AgentContext, EncryptedMessage, TransportSession } from '@aries-framework/core' | ||
import type { Ble } from '@animo-id/react-native-ble-didcomm' | ||
import type { AgentContext, EncryptedMessage, TransportSession } from '@aries-framework/core' | ||
|
||
import { utils } from '@aries-framework/core' | ||
|
||
export class BleTransportSession implements TransportSession { | ||
public readonly type = 'ble' | ||
public id: string | ||
private agent: Agent | ||
private central: Central | ||
|
||
public constructor(id: string, central: Central, agent: Agent) { | ||
private agentContext: AgentContext | ||
private messenger: Ble | ||
|
||
public constructor(id: string, messenger: Ble, agentContext: AgentContext) { | ||
this.id = id ?? utils.uuid() | ||
this.agent = agent | ||
this.central = central | ||
this.messenger = messenger | ||
this.agentContext = agentContext | ||
} | ||
|
||
public async send(agentContext: AgentContext, encryptedMessage: EncryptedMessage): Promise<void> { | ||
const serializedMessage = JSON.stringify(encryptedMessage) | ||
|
||
this.agent.config.logger.debug('Sending BLE inbound message via session') | ||
await this.central.sendMessage(serializedMessage) | ||
agentContext.config.logger.debug('Sending BLE inbound message via session') | ||
await this.messenger.sendMessage(serializedMessage) | ||
} | ||
|
||
public async close(): Promise<void> { | ||
this.agent.config.logger.debug('Stopping BLE inbound session') | ||
this.agentContext.config.logger.debug('Stopping BLE inbound session') | ||
} | ||
} |