Connecting to a data channel with Ably
async function connect() { | |
// set up an instance of the Ably realtime library | |
const ably = new Ably.Realtime.Promise({ authUrl: '/api/createTokenRequest' }); | |
// create a channel called "tshirt" | |
const channelId = "tshirt"; | |
//connect to the tshirt channel | |
const channel = await ably.channels.get(channelId); | |
await channel.attach(); | |
//subscribe to the channel to get updates and call processMessage | |
channel.subscribe(processMessage); | |
} | |
connect(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment