Created
October 20, 2021 10:31
-
-
Save velotiotech/9740a04578742b4603476ef94b2e5793 to your computer and use it in GitHub Desktop.
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
console.log(`Received socket connectionId: ${event.requestContext && event.requestContext.connectionId}`); | |
if (!(event.requestContext && event.requestContext.connectionId)) { | |
throw new Error('Invalid event. Missing `connectionId` parameter.'); | |
} | |
const connectionId = event.requestContext.connectionId; | |
const route = event.requestContext.routeKey; | |
console.log(`data from ${connectionId} ${event.body}`); | |
const connection = new Client(connectionId); | |
const response = { statusCode: 200, body: '' }; | |
if (route === '$connect') { | |
console.log(`Route ${route} - Socket connectionId connectedconected: ${event.requestContext && event.requestContext.connectionId}`); | |
await new Client(connectionId).connect(); | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment