Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
send(response, session) {
let contentFormat = ContentFormat.OctetStream;
switch (typeof response) {
case 'string':
response = ArrayBuffer.fromString(response);
contentFormat = ContentFormat.PlainText;
// fallthrough
case 'object':
if (response instanceof ArrayBuffer) {
response = session.createResponse(response, contentFormat);
}
break;
}
response.token = session.token;
if (!response.code) response.code = [2, 5];
if (!response.options) response.options = [];
if (session.confirmable && !session.response && !session.ackSent) {
response.type = Type.Ack;
response.messageId = session.messageId;