Last active
October 17, 2019 20:27
-
-
Save simontabor/6911ac30a6f214c2250fdc268973c10b 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
interface MessageAction { | |
action: 'subscribe' | 'unsubscribe'; | |
message: { | |
// Which room to subscribe to or unsubscribe from | |
room: string; | |
// Whether to "dump" existing messages for this room | |
dump: boolean; | |
}; | |
} | |
const wsMessage: MessageAction[] = [ | |
{ | |
action: 'subscribe', | |
message: { | |
room: 'testing', | |
dump: true, | |
}, | |
}, | |
]; | |
const ws = new WebSocket(`wss://${PUBBY_HOST}`); | |
ws.on('open', () => { | |
// Subscribe to the "testing" room and request a dump of existing data | |
ws.send(JSON.stringify(wsMessage)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment