Skip to content

Instantly share code, notes, and snippets.

@thisisjofrank
Created April 22, 2022 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thisisjofrank/58157ccbcbde01c5f105afd6634761e0 to your computer and use it in GitHub Desktop.
Save thisisjofrank/58157ccbcbde01c5f105afd6634761e0 to your computer and use it in GitHub Desktop.
he constructor takes a channelName to connect to, and generates an id for this client. In this implementation, we create a new Ably instance, and connect to the channelName which was given, passing a generated clientId.
constructor(channelName: string) {
this.id = Math.floor(Math.random() * 1000000) + "";
this.ably = new Ably.Realtime({ key: "api-key-here", clientId: this.id });
this.channel = this.ably.channels.get(channelName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment