Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added option to disable multiplexing

  • Loading branch information...
commit ab977c8862e553156eb456b44565927234024cbd 1 parent 7ef4198
@jfd jfd authored
Showing with 21 additions and 11 deletions.
  1. +4 −1 README.md
  2. +17 −10 index.js
View
5 README.md
@@ -96,7 +96,7 @@ Dispatch a signal on the specified `'url'` whithout creating a new `hydna.Channe
Note: This function is a complement to the ordinary Hydna Channel and should be used when a persistent connection is redundant.
-### hydna.createChannel(url, mode, [callback])
+### hydna.createChannel(url, mode, [options], [callback])
Opens a Channel to the specified ´'url'´.
@@ -108,6 +108,9 @@ Available modes:
* readwrite (rw) - Open channel in read-write mode.
* +emit(e) - Open channel with emit-signal support (e.g. 'rw+emit').
+Available options:
+* `disableMultiplex`, disables multiplexing of channels over one socket. Default is `false` (multiplex is enabled),
+
This example opens a Channel and writes data too it. The same data
is received :
View
27 index.js
@@ -64,27 +64,34 @@ exports.agent = 'node-wink-client/' + VERSION;
var connections = {};
-function createChannel(url, mode, C) {
+function createChannel(url, mode, opts, C) {
var connection;
var channel;
var urlobj;
var connurl;
var path;
+ if (typeof opts == 'function') {
+ C = opts;
+ opts = null;
+ }
+
urlobj = parseHydnaUrl(url);
connurl = createConnectionUrl(urlobj);
path = urlobj.pathname;
- if (Array.isArray(connections[connurl])) {
- for (var i = 0; i < connections[connurl].length; i++) {
- if (path in connections[connurl][i].channels == false) {
- connection = connections[connurl][i];
- break;
+ if (!opts || !opts.disableMultiplex) {
+ if (Array.isArray(connections[connurl])) {
+ for (var i = 0; i < connections[connurl].length; i++) {
+ if (path in connections[connurl][i].channels == false) {
+ connection = connections[connurl][i];
+ break;
+ }
+ }
+ } else if (connections[connurl]) {
+ if (path in connections[connurl].channels == false) {
+ connection = connections[connurl];
}
- }
- } else if (connections[connurl]) {
- if (path in connections[connurl].channels == false) {
- connection = connections[connurl];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.