anteton-chat-client
v1.2.6
Published
client
Downloads
31
Readme
example:
const Client = require('anteton-chat-client');
const client = new Client({url: 'url to the WS server', username: 'username', auth: 'authorization stuff'});
client.onopen(() => {
client.say('hello!');
client.onmessage((msg) => {
if (msg.username !== 'bot') {
client.say(`${msg.username}: ${msg.message}`);
}
if (msg.message == '/close' && msg.username !== 'bot') {
client.close();
}
});
client.onclose(() => {
console.log('disconnected!');
});
client.onuserjoin((username) => {
client.say(`'hello @${username}'`);
});
client.onuserleave((username) => {
client.say(`bye @${username}`);
});
});