Skip to content

Instantly share code, notes, and snippets.

@thisisjofrank
Created April 22, 2022 13:11
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/df74a2994e3dc860df8839e2c291922c to your computer and use it in GitHub Desktop.
Save thisisjofrank/df74a2994e3dc860df8839e2c291922c to your computer and use it in GitHub Desktop.
The connect method is going to subscribe to the presence event on the channel, passing the onSwarmPresenceChanged callback to be called when an event occurs. Once subscribed, we're going to enter presence, with a state of "connected", and call the onConnection callback:
public async connect() {
this.channel.presence.subscribe(this.onPresenceChanged.bind(this));
await this.channel.presence.enter('connected');
this.onConnection(this.channel);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment