-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
103 additions
and
43 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
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
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 @@ | ||
function process() { | ||
if (this.bundles.length > this.peer.options.maxBundle) { | ||
this._bundleTimer = setTimeout(this._tick.bind(this), this.peer.options.bundleDelay); | ||
} | ||
else { | ||
this._bundleTimer = null; | ||
} | ||
|
||
this.adapter.prototype.send.call(this, encoders[this.peer.options.encoder].encode(this.bundles.splice(0, this.peer.options.maxBundle))); | ||
this.onComplete.dispatch(); | ||
} | ||
// Bundling logic | ||
// ----------------------------- | ||
// Add new calls to the bundle stack | ||
// If stack length exceeds limit OR | ||
// If time since last chunk sent is greater than the delay - | ||
// AND there is an item in the stack | ||
// Send. | ||
// If an item is added and delay timer is not started, start it. | ||
|
||
module.exports = { | ||
process: process | ||
}; |
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,26 @@ | ||
var Kalm = require('../index'); | ||
|
||
var server = new Kalm.Server({ | ||
port: 3000, | ||
adapter: 'ipc', | ||
encoder: 'msg-pack' | ||
}); | ||
|
||
server.on('connection', function(client) { | ||
console.log('client'); | ||
console.log(client); | ||
}); | ||
|
||
server.on('ready', function() { | ||
var client = new Kalm.Client({ | ||
port: 3000, | ||
adapter: 'ipc', | ||
encoder:'msg-pack', | ||
hostname: '0.0.0.0' | ||
}); | ||
|
||
client.channel('rare_pepes').send('kalm_pepe'); | ||
client.channel('rare_pepes').send('kalm_doge'); | ||
|
||
client.channel().send('klam klam'); | ||
}); |
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