Create a chat room

The ChatEngine.Chat() class allows you to create a new chat room. The user will automatically join the chat room when it is created if the autoConnect flag is set to true.

All chat rooms are created as public by default. A private chat room can be created by setting the isPrivate flag to true.

Public Chat

let chat = new ChatEngine.Chat('public-chat');

Private Chat

let privateChat = new ChatEngine.Chat('private-chat', true);

You can get a list of all chat rooms by using ChatEngine.chats .

console.log(ChatEngine.chats);
chat = ChatEngine.chats['public-chat'];

Chat metadata

The ChatEngine.Chat() class can also define chat metadata for a chat room. Chat metadata persists on the server and can be accessed by calling chat.meta .

let chat = new ChatEngine.Chat('public-chat', false, true,{
    name: 'Soccer meetup',
    team: 'A'
});

The chat.update() method allows you to update chat metadata.

chat.update({
    name: 'Soccer meetup',
    team: 'B'
});