mirror of
https://github.com/status-im/status-js-api.git
synced 2025-02-18 04:16:42 +00:00
24 lines
460 B
JavaScript
24 lines
460 B
JavaScript
const StatusJS = require('../dist/index.js');
|
|
|
|
(async () => {
|
|
const status = new StatusJS();
|
|
|
|
await status.connect("ws://localhost:8546");
|
|
|
|
await status.joinChat("mytest");
|
|
|
|
status.onMessage("mytest", (err, data) => {
|
|
if(err) {
|
|
console.error("Error: " + err);
|
|
return;
|
|
}
|
|
|
|
console.log("message received:");
|
|
console.dir(data);
|
|
});
|
|
|
|
setInterval(() => {
|
|
status.sendMessage("#mytest", "hello world!");
|
|
}, 3000);
|
|
})();
|