eventsocket
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -15,19 +15,19 @@ var net = require('net'); | ||
function EventSocket(ip, port) { | ||
function EventSocket() { | ||
var eventSocket = this; | ||
var socket; | ||
if (isString(ip)) { | ||
log('connecting... %s:%s', ip, port); | ||
socket = new JsonSocket(ip, port); | ||
} else if (ip instanceof JsonSocket) { | ||
socket = ip; | ||
} else if (ip instanceof net.Socket) { | ||
socket = new JsonSocket(ip); | ||
if (arguments[0] instanceof JsonSocket) { | ||
socket = arguments[0]; | ||
} else if (arguments[0] instanceof net.Socket) { | ||
socket = new JsonSocket(arguments[0]); | ||
} else { | ||
return; | ||
var args = Array.prototype.concat.apply([null], arguments); | ||
socket = new (Function.prototype.bind.apply(JsonSocket, args))(); | ||
} | ||
socket.on('connect', function () { | ||
log('connect'); | ||
emit('connect'); | ||
}); | ||
socket.on('json', function (json) { | ||
@@ -57,2 +57,6 @@ if (isString(json.name)) { | ||
eventSocket.connect = function () { | ||
socket.connect.apply(socket, arguments); | ||
}; | ||
var _emit = eventSocket.emit; | ||
@@ -59,0 +63,0 @@ |
{ | ||
"name": "eventsocket", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Event socket", | ||
@@ -27,3 +27,3 @@ "main": "index.js", | ||
"debug": "^2.1.1", | ||
"jsonsocket": "^1.0.1" | ||
"jsonsocket": "^1.0.2" | ||
}, | ||
@@ -30,0 +30,0 @@ "devDependencies": { |
@@ -18,5 +18,7 @@ # eventsocket | ||
### `EventSocket(ip, port)` | ||
### `EventSocket(options)` | ||
### `EventSocket(port, [host])` | ||
### `EventSocket(path)` | ||
Create new event socket from ip and port. | ||
Create new event socket. Same as [`net.connect`](http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener). | ||
@@ -49,2 +51,8 @@ ```js | ||
### `connect(port, [host])` | ||
### `connect(path)` | ||
Same as [`net.Socket.connect`](http://nodejs.org/api/net.html#net_socket_connect_port_host_connectlistener) | ||
### `on(eventType, listener)` | ||
@@ -51,0 +59,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7474
74
108
Updatedjsonsocket@^1.0.2