in src/main/java/com/amazonaws/kvstranscribestreaming/publisher/WebSocketTranscriptionPublisher.java [119:150]
private String getConnectionId() {
if(this.connectionId == null) {
GetItemSpec fromNumberSpec = new GetItemSpec()
.withPrimaryKey(NUMBER, detail.getFromNumber())
.withConsistentRead(true)
.withProjectionExpression(CONNECTION_ID);
GetItemSpec toNumberSpec = new GetItemSpec()
.withPrimaryKey(NUMBER, detail.getToNumber())
.withConsistentRead(true)
.withProjectionExpression(CONNECTION_ID);
Item fromNumberItem = getDDBClient().getTable(WEBSOCKET_MAPPING_TABLE_NAME).getItem(fromNumberSpec),
toNumberItem = getDDBClient().getTable(WEBSOCKET_MAPPING_TABLE_NAME).getItem(toNumberSpec);
if (fromNumberItem != null && fromNumberItem.hasAttribute(CONNECTION_ID)) {
this.connectionId = (String) fromNumberItem.get(CONNECTION_ID);
logger.info("{} connection is associated with from number {} and id {}, starting transmission", WEB_SOCKET_PUBLISHER_PREFIX, detail.getFromNumber(), this.connectionId);
return this.connectionId;
}
if (toNumberItem != null && toNumberItem.hasAttribute(CONNECTION_ID)) {
this.connectionId = (String) toNumberItem.get(CONNECTION_ID);
logger.info("{} connection is associated with to number {} and id {}, starting transmission", WEB_SOCKET_PUBLISHER_PREFIX, detail.getToNumber(), this.connectionId);
return this.connectionId;
}
logger.info("{} cannot get connection id associated with number {} or number {} in dynamodb table. ", WEB_SOCKET_PUBLISHER_PREFIX, detail.getFromNumber(), detail.getToNumber());
}
return this.connectionId;
}