Following this example project: https://github.com/aws-samples/simple-websockets-chat-app
The onconnect method looks like this:
const AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB.DocumentClient({ apiVersion: '2012-08-10', region: process.env.AWS_REGION });
exports.handler = async event => {
const putParams = {
TableName: process.env.TABLE_NAME,
Item: {
connectionId: event.requestContext.connectionId
}
};
try {
await ddb.put(putParams).promise();
} catch (err) {
return { statusCode: 500, body: 'Failed to connect: ' + JSON.stringify(err) };
}
return { statusCode: 200, body: 'Connected.' };
};
How can I see what other fields this
eventobject has? I can't find the documentation.Can I pass in a parameter from the client when connecting to the websocket? Like
wss://path.to.socket/someparameterand how do I access it from thiseventobject?
I want to add another parameter to the database:
const putParams = {
TableName: process.env.TABLE_NAME,
Item: {
connectionId: event.requestContext.connectionId,
someparameter: event.someparameter // <-- What's the right way?
}
};
Thanks!