1.2.6 • Published 2 years ago
anteton-chat-client
Licence
ISC
Version
1.2.6
Deps
1
Size
3 kB
Vulns
0
Weekly
0
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}`);
});
});