-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from kalm/v3.2.0
V3.2.0
- Loading branch information
Showing
72 changed files
with
687 additions
and
1,227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
**/*.min.js | ||
*.js | ||
examples | ||
node_modules | ||
node_modules | ||
scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ tslint.json | |
package-lock.json | ||
yarn.lock | ||
.vscode | ||
.github | ||
.github | ||
jest.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
language: node_js | ||
cache: yarn | ||
node_js: | ||
- "12" | ||
- "10" | ||
- "8" | ||
script: | ||
- yarn run lint | ||
- yarn run test | ||
- yarn run build | ||
- yarn run bench | ||
sudo: false | ||
install: | ||
- yarn | ||
before_install: | ||
- npm install yarn@^1.13.0 | ||
- npm install yarn@^1.19.0 | ||
- yarn --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const kalm = require('kalm'); | ||
const ws = require('@kalm/ws'); | ||
const snappy = require('snappy'); | ||
|
||
const Client = kalm.connect({ | ||
transport: ws(), | ||
port: 3938, | ||
json: false, | ||
routine: kalm.routines.realtime(), | ||
}); | ||
|
||
Client.subscribe('foo', (body, frame) => { | ||
snappy.uncompress(body, (decompressedMessage) => { | ||
console.log('Server event', decompressedMessage, frame); | ||
}); | ||
}); | ||
|
||
const payload = { | ||
foo: 'bar', | ||
message: 'hello from the client!', | ||
}; | ||
|
||
Client.write('foo', snappy.compressSync(Buffer.from(JSON.stringify(payload)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const kalm = require('kalm'); | ||
const ws = require('@kalm/ws'); | ||
const snappy = require('snappy'); | ||
|
||
const provider = kalm.listen({ | ||
label: 'internal', | ||
transport: ws(), | ||
port: 3000, | ||
json: false, | ||
routine: kalm.routines.realtime(), | ||
host: '0.0.0.0', // Apply local ip | ||
}); | ||
|
||
provider.on('connection', (client) => { | ||
client.subscribe('foo', (body, frame) => { | ||
snappy.uncompress(body, (decompressedMessage) => { | ||
console.log('Client event', decompressedMessage, frame); | ||
}); | ||
}); | ||
|
||
const payload = { | ||
foo: 'bar', | ||
message: 'hello from the server!', | ||
}; | ||
|
||
client.write('foo', snappy.compressSync(Buffer.from(JSON.stringify(payload)))); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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 = { | ||
foo: 'bar', | ||
message: 'hello from the server!', | ||
}; | ||
|
||
client.write('foo', payload); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
globals: { | ||
'ts-jest': { | ||
diagnostics: false, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
{ | ||
"name": "kalm-lerna", | ||
"private": true, | ||
"version": "3.1.2", | ||
"version": "3.2.0", | ||
"description": "The socket optimizer", | ||
"main": "packages/kalm/bin/kalm.js", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"lint": "eslint **/*.ts **/*.spec.ts", | ||
"lint:fix": "yarn lint --fix", | ||
"test": "yarn workspaces run test --ci && mocha ./tests/integration --exit", | ||
"test": "jest ./packages && jest ./tests/integration --forceExit", | ||
"build": "yarn workspaces run build --ci", | ||
"clean": "yarn workspaces run clean --ci", | ||
"bench": "node ./scripts/benchmarks" | ||
}, | ||
"repository": { | ||
|
@@ -24,20 +25,28 @@ | |
"contributors": [ | ||
"frederic charette <[email protected]>" | ||
], | ||
"typings": "./types.ts", | ||
"workspaces": [ "packages/*" ], | ||
"typings": "./types.d.ts", | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn lint" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^12.0.0", | ||
"@typescript-eslint/eslint-plugin": "^1.10.2", | ||
"@typescript-eslint/parser": "^1.10.0", | ||
"chai": "^4.2.0", | ||
"eslint": "^5.16.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.8.0", | ||
"mocha": "^6.1.0", | ||
"rollup": "^1.15.0", | ||
"socket.io": "^2.2.0", | ||
"socket.io-client": "^2.2.0", | ||
"typescript": "^3.5.0" | ||
"@types/jest": "^24.0.17", | ||
"@types/node": "^12.7.0", | ||
"@typescript-eslint/eslint-plugin": "^2.3.0", | ||
"@typescript-eslint/parser": "^2.3.0", | ||
"eslint": "^6.5.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-plugin-import": "^2.18.0", | ||
"husky": "^3.0.8", | ||
"jest": "^24.9.0", | ||
"socket.io": "^2.3.0", | ||
"socket.io-client": "^2.3.0", | ||
"ts-jest": "^24.1.0", | ||
"typescript": "^3.6.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.