Skip to content

Instantly share code, notes, and snippets.

@astrotars
Created February 26, 2020 15:58
Show Gist options
  • Save astrotars/e0df0a7fc1850269169e61feb95849d1 to your computer and use it in GitHub Desktop.
Save astrotars/e0df0a7fc1850269169e61feb95849d1 to your computer and use it in GitHub Desktop.
async function initializeClient(username) {
const token = await generateToken(username);
// Set the current logged user
client.setUser(
{
id: username,
name: 'Jon Snow', // Update this name dynamically
image: 'https://bit.ly/2u9Vc0r'
},
token
); // token generated from our PHP server
// create or initialize the channel
channel = client.channel('messaging', 'general-channel1', {
name: 'General Room for platform',
image: 'https://bit.ly/2F3KEoM',
members: [],
session: 8 // custom field, you can add as many as you want
});
// Watch the channel for events
await channel.watch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment