Skip to content

Commit 55ce276

Browse files
authored
Merge pull request #20 from kalm/v3.2.0
V3.2.0
2 parents fac8047 + f583925 commit 55ce276

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+687
-1227
lines changed

.eslintignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
**/*.min.js
1+
*.js
22
examples
3-
node_modules
3+
node_modules
4+
scripts

.eslintrc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"import/resolver": {
77
"node": {
88
"paths": ["packages"],
9-
"extensions": [".js", ".json", ".ts"]
9+
"extensions": [".ts", ".spec.ts"]
1010
}
1111
}
1212
},
@@ -17,6 +17,12 @@
1717
"object-curly-newline": 0,
1818
"no-plusplus": 0,
1919
"no-unused-expressions": 0,
20+
"guard-for-in": 0,
21+
"no-mixed-operators": 0,
22+
"no-param-reassign": 0,
23+
"arrow-parens": [2, "as-needed"],
24+
"import/prefer-default-export": 0,
25+
"no-continue": 0,
2026
"no-unused-vars": 0,
2127
"global-require": 0,
2228
"@typescript-eslint/no-unused-vars": [
@@ -27,7 +33,7 @@
2733
},
2834
"env": {
2935
"browser": true,
30-
"mocha": true,
36+
"jest": true,
3137
"node": true
3238
}
3339
}

.gitignore

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,18 @@ NTH
4141
docs
4242
yarn.lock
4343
package-lock.json
44-
.vscode
44+
.vscode
45+
46+
# built code
47+
packages/kalm/bin
48+
packages/ipc/bin
49+
packages/tcp/bin
50+
packages/udp/bin
51+
packages/ws/bin
52+
53+
# built types reference
54+
packages/kalm/types.d.ts
55+
packages/ipc/types.d.ts
56+
packages/tcp/types.d.ts
57+
packages/udp/types.d.ts
58+
packages/ws/types.d.ts

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ tslint.json
99
package-lock.json
1010
yarn.lock
1111
.vscode
12-
.github
12+
.github
13+
jest.config.js

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
language: node_js
22
cache: yarn
33
node_js:
4+
- "12"
45
- "10"
5-
- "8"
66
script:
77
- yarn run lint
88
- yarn run test
9+
- yarn run build
910
- yarn run bench
1011
sudo: false
1112
install:
1213
- yarn
1314
before_install:
14-
- npm install yarn@^1.13.0
15+
- npm install yarn@^1.19.0
1516
- yarn --version
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const kalm = require('kalm');
22
const ws = require('@kalm/ws');
3+
34
const { randomBytes } = require('crypto');
45

56
const Client = kalm.connect({
@@ -10,8 +11,8 @@ const Client = kalm.connect({
1011
routine: kalm.routines.realtime(),
1112
});
1213

13-
Client.subscribe('r.evt', (evt, frame) => console.log(`${evt.name}: ${evt.msg}`, frame));
14-
Client.subscribe('r.sys', (evt, frame) => console.log(`[System]: ${evt.msg}`, frame));
14+
Client.subscribe('r.evt', (body, frame) => console.log(`${body.name}: ${body.msg}`, frame));
15+
Client.subscribe('r.sys', (body, frame) => console.log(`[System]: ${body.msg}`, frame));
1516

1617
Client.on('connect', () => {
1718
Client.write('c.evt', { name: Client.label, msg: 'Hey everyone!' });
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const Server = kalm.listen({
1010
});
1111

1212
Server.on('connection', (client) => {
13-
client.subscribe('c.evt', (msg, evt) => {
14-
Server.broadcast('r.evt', msg);
13+
client.subscribe('c.evt', (body, frame) => {
14+
Server.broadcast('r.evt', body);
1515
});
1616

1717
Server.broadcast('r.sys', { msg: 'user joined' });

examples/compression/client.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const kalm = require('kalm');
2+
const ws = require('@kalm/ws');
3+
const snappy = require('snappy');
4+
5+
const Client = kalm.connect({
6+
transport: ws(),
7+
port: 3938,
8+
json: false,
9+
routine: kalm.routines.realtime(),
10+
});
11+
12+
Client.subscribe('foo', (body, frame) => {
13+
snappy.uncompress(body, (decompressedMessage) => {
14+
console.log('Server event', decompressedMessage, frame);
15+
});
16+
});
17+
18+
const payload = {
19+
foo: 'bar',
20+
message: 'hello from the client!',
21+
};
22+
23+
Client.write('foo', snappy.compressSync(Buffer.from(JSON.stringify(payload))));

examples/compression/server.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const kalm = require('kalm');
2+
const ws = require('@kalm/ws');
3+
const snappy = require('snappy');
4+
5+
const provider = kalm.listen({
6+
label: 'internal',
7+
transport: ws(),
8+
port: 3000,
9+
json: false,
10+
routine: kalm.routines.realtime(),
11+
host: '0.0.0.0', // Apply local ip
12+
});
13+
14+
provider.on('connection', (client) => {
15+
client.subscribe('foo', (body, frame) => {
16+
snappy.uncompress(body, (decompressedMessage) => {
17+
console.log('Client event', decompressedMessage, frame);
18+
});
19+
});
20+
21+
const payload = {
22+
foo: 'bar',
23+
message: 'hello from the server!',
24+
};
25+
26+
client.write('foo', snappy.compressSync(Buffer.from(JSON.stringify(payload))));
27+
});

examples/distributed_pub_sub/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const Client = kalm.connect({
1111
routine: kalm.routines.realtime(),
1212
});
1313

14-
Client.subscribe('r.evt', (evt, frame) => {
15-
console.log('Relayed event', evt, frame);
14+
Client.subscribe('r.evt', (body, frame) => {
15+
console.log('Relayed event', body, frame);
1616
});
1717

1818
// now send some events

0 commit comments

Comments
 (0)