Skip to content

Instantly share code, notes, and snippets.

@Farouk-Lamri
Farouk-Lamri / publish.js
Last active February 6, 2020 09:29
Example of postToConnection for aws websocket
var AWS = require('aws-sdk');
var credentials = new AWS.SharedIniFileCredentials({profile: 'sma-testing-cloudformation'});
AWS.config.credentials = credentials;
const endpoint = "shkknwbjca.execute-api.eu-west-1.amazonaws.com/v1"
var apigatewaymanagementapi = new AWS.ApiGatewayManagementApi({endpoint:endpoint,apiVersion:"2018-11-29",region:"eu-west-1"});
const dynamoClient = new AWS.DynamoDB({apiVersion: '2012-08-10',region:'eu-west-1'});
let id = "1" // id of connected user. You can retrieve it from your database
let message = "Hello from SMA" // message to send to the user
// function to get user connection id thanks to userId
### Keybase proof
I hereby claim:
* I am farouk-lamri on github.
* I am farouklamri (https://keybase.io/farouklamri) on keybase.
* I have a public key ASA65Nk68Kr0a0imfaXaozwSmTVor0eEPLUrw3T_MhceMAo
To claim this, I am signing this object: