Renamed Socket#write > Socket#sendPacket

This commit is contained in:
Guillermo Rauch
2011-12-21 10:48:45 -08:00
parent cb573c51e5
commit 976ecd4956

View File

@@ -142,7 +142,7 @@ Socket.prototype.probe = function (name) {
, self = this
transport.once('open', function () {
transport.write(parser.encodePacket('ping'));
transport.send({ type: 'ping' });
transport.once('message', function (message) {
if ('pong' == message.type) {
self.upgrading = true;
@@ -218,7 +218,7 @@ Socket.prototype.onMessage = function (msg) {
break;
case 'ping':
this.write('pong');
this.sendPacket('pong');
break;
case 'error':
@@ -263,19 +263,19 @@ Socket.prototype.flush = function () {
*/
Socket.prototype.send = function (msg) {
this.write('message', msg);
this.sendPacket('message', msg);
return this;
};
/**
* Writes data.
* Sends a packet.
*
* @param {String} packet type.
* @param {String} data.
* @api private
*/
Socket.prototype.write = function (type, data) {
Socket.prototype.sendPacket = function (type, data) {
var packet = { type: type, data: data };
if ('open' != this.readyState || this.upgrading) {
this.writeBuffer.push(packet);