0.0.2 • Published 8 months ago

ckecord.js v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

ckecord.js


a very barebones library for a simple internal chat app

this was written in about an hour, so don't expect high quality or polished code

this is how you use it (this is currently the only documentation available)

const ckecord = require('ckecord.js');
const client = new ckecord.Client('wss://localhost', '/server/server', 'testuser', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjYGBg+A8AAQQBAHAgZQsAAAAASUVORK5CYII=');

// username and avatar can also be altered with client.username and client.avatar
// these are sent along with other events, so there's no need (or way) to notify the server of the changes

client.on("connect", ()=> {
    client.announceJoin(); // will announce your join, the original client does it automatically upon connecting, is not required but recommended
    client.sendMessage({content: "moving to Hodowla zwierzątek domowych if anyone needs me"});
    client.changeRoom({roomName: "Hodowla zwierzątek domowych"}); // the server will automatically announce your join in the new room
})
client.on("connect_error", (err)=> {
    throw new Error (err);
})
client.on("changeRoom", (room)=> {
    console.log(`moved to room ${room.roomName}!`);
})
client.on("userJoin", (user)=>{
    if (user.username !== "boss") {
        client.sendMessage({content: `hey!`});
    } else {
        client.logout();
    }
})
client.on("userLeave", (user)=>{
    client.sendMessage({content: `sad to see ${user.username} go :(`});
})
client.on("message", (message)=>{
    // message.avatar can also be used and its a string with a data url in it
    console.log(`${message.username}: ${message.content}`)
})

client.login();
0.0.2

8 months ago

0.0.1

8 months ago