Skip to content

Commit

Permalink
Add new config parameters for WebSocket-Node.
Browse files Browse the repository at this point in the history
Use the new fork of WebSocket-Node I created.
  • Loading branch information
GICodeWarrior committed Aug 10, 2012
1 parent 62f3024 commit face934
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 36 deletions.
115 changes: 80 additions & 35 deletions lib/transports/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,86 @@ function WebSocket (mng, data, req) {
var self = this;

this.websocketConfig = {
// 64KiB max frame size.
maxReceivedFrameSize: 0x10000,

// 1MiB max message size, only applicable if
// assembleFragments is true
maxReceivedMessageSize: 0x100000,

// Outgoing messages larger than fragmentationThreshold will be
// split into multiple fragments.
fragmentOutgoingMessages: false,

// Outgoing frames are fragmented if they exceed this threshold.
// Default is 16KiB
fragmentationThreshold: 0x4000,

// If true, the server will automatically send a ping to all
// clients every 'keepaliveInterval' milliseconds.
keepalive: false,

// The interval to send keepalive pings to connected clients.
keepaliveInterval: 20000,

// If true, fragmented messages will be automatically assembled
// and the full message will be emitted via a 'message' event.
// If false, each frame will be emitted via a 'frame' event and
// the application will be responsible for aggregating multiple
// fragmented frames. Single-frame messages will emit a 'message'
// event in addition to the 'frame' event.
// Most users will want to leave this set to 'true'
assembleFragments: true,

// The number of milliseconds to wait after sending a close frame
// for an acknowledgement to come back before giving up and just
// closing the socket.
closeTimeout: 5000
// 64KiB max frame size.
maxReceivedFrameSize: 0x10000,

// 1MiB max message size, only applicable if
// assembleFragments is true
maxReceivedMessageSize: 0x100000,

// Outgoing messages larger than fragmentationThreshold will be
// split into multiple fragments.
fragmentOutgoingMessages: true,

// Outgoing frames are fragmented if they exceed this threshold.
// Default is 16KiB
fragmentationThreshold: 0x4000,

// If true, the server will automatically send a ping to all
// clients every 'keepaliveInterval' milliseconds. The timer is
// reset on any received data from the client.
keepalive: false,

// The interval to send keepalive pings to connected clients if the
// connection is idle. Any received data will reset the counter.
keepaliveInterval: 20000,

// If true, the server will consider any connection that has not
// received any data within the amount of time specified by
// 'keepaliveGracePeriod' after a keepalive ping has been sent.
// Ignored if keepalive is false.
dropConnectionOnKeepaliveTimeout: true,

// The amount of time to wait after sending a keepalive ping before
// closing the connection if the connected peer does not respond.
// Ignored if keepalive is false.
keepaliveGracePeriod: 10000,

// If true, fragmented messages will be automatically assembled
// and the full message will be emitted via a 'message' event.
// If false, each frame will be emitted via a 'frame' event and
// the application will be responsible for aggregating multiple
// fragmented frames. Single-frame messages will emit a 'message'
// event in addition to the 'frame' event.
// Most users will want to leave this set to 'true'
assembleFragments: true,

// If this is true, websocket connections will be accepted
// regardless of the path and protocol specified by the client.
// The protocol accepted will be the first that was requested
// by the client. Clients from any origin will be accepted.
// This should only be used in the simplest of cases. You should
// probably leave this set to 'false' and inspect the request
// object to make sure it's acceptable before accepting it.
autoAcceptConnections: false,

// The Nagle Algorithm makes more efficient use of network resources
// by introducing a small delay before sending small packets so that
// multiple messages can be batched together before going onto the
// wire. This however comes at the cost of latency, so the default
// is to disable it. If you don't need low latency and are streaming
// lots of small messages, you can change this to 'false'
disableNagleAlgorithm: true,

// The number of milliseconds to wait after sending a close frame
// for an acknowledgement to come back before giving up and just
// closing the socket.
closeTimeout: 5000,

// Socket is pause()'ed if the receive buffer contains too much
// unprocessed data. This forces the client to back off if the server
// is slow. This is a soft limit (no way to set socket receive
// buffer), so a single socket data event may provide more than this
// limit.
// Default is 16KiB
receiveBufferSize: 0x4000,

// Message handling is deferred to the end of the event queue if it
// blocks for longer than this limit. This is a soft limit (no way to
// preempt), so handling a single message may block longer than this
// limit.
// Default is 1ms
messageBlockingTime: 1
};

Transport.call(this, mng, data, req);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"socket.io-client": "0.9.9"
, "policyfile": "0.0.4"
, "redis": "0.7.2"
, "websocket": "1.0.6"
, "websocket": "git://github.com/GICodeWarrior/WebSocket-Node.git"
}
, "devDependencies": {
"expresso": "0.9.2"
Expand Down

0 comments on commit face934

Please sign in to comment.