mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
@@ -5,5 +5,4 @@ tunnel:
|
||||
authtoken: 6Aw8vTgcG5EvXdQywVvbh_3fMxvd4Q7dcL2caAHAFjV
|
||||
proto: tcp
|
||||
browserify:
|
||||
- exclude: bufferutil
|
||||
- exclude: utf-8-validate
|
||||
- ignore: ws
|
||||
|
||||
@@ -51,7 +51,7 @@ Engine.IO is a commonjs module, which means you can include it by using
|
||||
1. build your app bundle
|
||||
|
||||
```bash
|
||||
$ browserify app.js > bundle.js
|
||||
$ browserify app.js -i ws > bundle.js
|
||||
```
|
||||
|
||||
1. include on your page
|
||||
|
||||
@@ -8,6 +8,7 @@ var parseqs = require('parseqs');
|
||||
var inherit = require('component-inherit');
|
||||
var yeast = require('yeast');
|
||||
var debug = require('debug')('engine.io-client:websocket');
|
||||
var BrowserWebSocket = global.WebSocket || global.MozWebSocket;
|
||||
|
||||
/**
|
||||
* Get either the `WebSocket` or `MozWebSocket` globals
|
||||
@@ -15,7 +16,7 @@ var debug = require('debug')('engine.io-client:websocket');
|
||||
* exposed by `ws` for Node environment.
|
||||
*/
|
||||
|
||||
var WebSocket = typeof window !== 'undefined' ? (window.WebSocket || window.MozWebSocket) : require('ws');
|
||||
var WebSocket = BrowserWebSocket || (typeof window !== 'undefined' ? null : require('ws'));
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
@@ -91,7 +92,7 @@ WS.prototype.doOpen = function(){
|
||||
opts.headers = this.extraHeaders;
|
||||
}
|
||||
|
||||
this.ws = new WebSocket(uri, protocols, opts);
|
||||
this.ws = BrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts);
|
||||
|
||||
if (this.ws.binaryType === undefined) {
|
||||
this.supportsBinary = false;
|
||||
@@ -158,15 +159,13 @@ WS.prototype.write = function(packets){
|
||||
var self = this;
|
||||
this.writable = false;
|
||||
|
||||
var isBrowserWebSocket = global.WebSocket && this.ws instanceof global.WebSocket;
|
||||
|
||||
// encodePacket efficient as it uses WS framing
|
||||
// no need for encodePayload
|
||||
var total = packets.length;
|
||||
for (var i = 0, l = total; i < l; i++) {
|
||||
(function(packet) {
|
||||
parser.encodePacket(packet, self.supportsBinary, function(data) {
|
||||
if (!isBrowserWebSocket) {
|
||||
if (!BrowserWebSocket) {
|
||||
// always create a new object (GH-437)
|
||||
var opts = {};
|
||||
if (packet.options) {
|
||||
@@ -185,7 +184,7 @@ WS.prototype.write = function(packets){
|
||||
//have a chance of informing us about it yet, in that case send will
|
||||
//throw an error
|
||||
try {
|
||||
if (isBrowserWebSocket) {
|
||||
if (BrowserWebSocket) {
|
||||
// TypeError is thrown when passing the second argument on Safari
|
||||
self.ws.send(data);
|
||||
} else {
|
||||
|
||||
@@ -28,8 +28,7 @@ function build(fn){
|
||||
insertGlobalVars: { global: glob },
|
||||
standalone: 'eio'
|
||||
})
|
||||
.exclude('bufferutil')
|
||||
.exclude('utf-8-validate')
|
||||
.ignore('ws')
|
||||
.bundle();
|
||||
|
||||
bundle.on('error', function (err) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// support in browsers and in node.js
|
||||
// some tests do not yet work in both
|
||||
exports.browser = !!global.window;
|
||||
exports.wsSupport = !!require('ws');
|
||||
exports.wsSupport = !!(!global.window || window.WebSocket || window.MozWebSocket);
|
||||
|
||||
var userAgent = global.navigator ? navigator.userAgent : '';
|
||||
exports.isOldSimulator = ~userAgent.indexOf('iPhone OS 4') || ~userAgent.indexOf('iPhone OS 5');
|
||||
|
||||
Reference in New Issue
Block a user