nodejs-websocket
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -168,2 +168,17 @@ /** | ||
/** | ||
* Sends a text or binary frame | ||
* @param {string|Buffer} data | ||
* @param {Function} [callback] will be executed when the data is finally written out | ||
*/ | ||
Connection.prototype.send = function (data, callback) { | ||
if (typeof data === 'string') { | ||
this.sendText(data, callback) | ||
} else if (Buffer.isBuffer(data)) { | ||
this.sendBinary(data, callback) | ||
} else { | ||
throw new TypeError('data should be either a string or a Buffer instance') | ||
} | ||
} | ||
/** | ||
* Sends a ping to the remote | ||
@@ -170,0 +185,0 @@ * @param {string} [data=''] - optional ping data |
@@ -0,1 +1,4 @@ | ||
# 1.5.0 | ||
* Added: `Connection#send` as a short hand for `Connection#sendText` or `Connection#sendBinary`, depending on the data type (string or Buffer) | ||
# 1.4.1 | ||
@@ -2,0 +5,0 @@ * Added: example to README |
{ | ||
"name": "nodejs-websocket", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"author": "Sitegui <sitegui@sitegui.com.br>", | ||
@@ -25,4 +25,4 @@ "description": "Basic server&client approach to websocket (text and binary frames)", | ||
"mocha": "^2.3.4", | ||
"should": "^7.1.1" | ||
"should": "^8.1.0" | ||
} | ||
} |
@@ -118,2 +118,7 @@ # Nodejs Websocket | ||
## connection.send(data, [callback]) | ||
Sends a given string or Buffer to the other side. This is simply an alias for `sendText()` if data is a string or `sendBinary()` if the data is a Buffer. | ||
`callback` will be added as a listener to write operation over the socket | ||
## connection.sendPing([data='']) | ||
@@ -120,0 +125,0 @@ Sends a [ping](http://tools.ietf.org/html/rfc6455#section-5.5.2) with optional payload |
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
37563
935
190