Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import kalm from 'kalm';
import ws from '@kalm/ws';
const client = kalm.connect({
transport: ws(),
port: 3938,
routine: kalm.routines.realtime(),
});
type MyCustomPayload = {
foo: string
message: string
};
client.subscribe('r.evt', (body: MyCustomPayload, frame) => {
console.log('Server event', body, frame);
});
client.write('c.evt', 'hello world!');
import kalm from 'kalm';
import ws from '@kalm/ws';
const provider = kalm.listen({
transport: ws(),
port: 3938,
routine: kalm.routines.tick(5),
host: '0.0.0.0',
});
type MyCustomPayload = {
foo: string
message: string
};
provider.on('connection', (client) => {
client.subscribe('foo', (body: MyCustomPayload, frame) => {
console.log('Client event', body, frame);
});
const payload: MyCustomPayload = {