Skip to content

Instantly share code, notes, and snippets.

@simontabor
Created October 17, 2019 20:40
Show Gist options
  • Save simontabor/e2676524c5d570864a1891119470fae5 to your computer and use it in GitHub Desktop.
Save simontabor/e2676524c5d570864a1891119470fae5 to your computer and use it in GitHub Desktop.
interface InboundMessage {
room: string;
id: string;
data: object;
version: number;
}
ws.on('message', (rawMsg: string) => {
const messages: InboundMessage[] = JSON.parse(rawMsg);
console.log(messages);
/*
* [
* {
* "room": "testing",
* "id": "1",
* "data": { "any": "info" },
* "version": 1
* }
* ]
*/
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment