Permalink
Browse files

[major] Remove socket.io transformer

  • Loading branch information...
lpinca committed Jun 24, 2016
1 parent 7e8bf15 commit aa0ae5700898ff3276dbce79ef0c9376ef22fd6b
View
@@ -73,7 +73,6 @@ repository.
- [BrowserChannel](#browserchannel)
- [Engine.IO](#engineio)
- [Faye](#faye)
- - [Socket.IO](#socketio)
- [SockJS](#sockjs)
- [uws](#uws)
- [WebSockets](#websockets)
@@ -1262,53 +1261,6 @@ var Socket = primus.Socket
, socket = new Socket('url');
```
-#### Socket.IO
-
-The Socket.IO transport was written against Socket.IO 0.9.x. It was one of the
-first real-time servers written on Node.js and is one of the most used modules
-in Node.js. It uses multiple transports to connect the server. To use Socket.IO
-you need to install the `socket.io` module:
-
-```
-npm install socket.io@0.9.x --save
-```
-
-And tell `Primus` that you want to use `socket.io` as transformer:
-
-```js
-var primus = new Primus(server, { transformer: 'socket.io' });
-```
-
-If you want to use the client interface inside of Node.js you also need to
-install the `primus-socket.io-client` module. This a fork of `socket.io-client`
-maintained by us to fix the bugs found on the 0.9 branch which is no longer
-supported upstream:
-
-```
-npm install primus-socket.io-client --save
-```
-
-If you want, you can opt out of our fixes and use the original `socket.io-client`.
-To do that just install `socket.io-client` instead of `primus-socket.io-client`:
-
-```
-npm install socket.io-client@0.9.x --save
-```
-
-And then you can access it from your server instance:
-
-```js
-var Socket = primus.Socket
- , socket = new Socket('url');
-```
-
-**Please keep in mind that the browser client will always use our fixes.**
-
-**Note: Primus will never support Socket.IO 1.0. As it's just an abstraction built
-upon Engine.IO so it makes more sense to use Engine.IO in Primus directly.
-Socket.IO 0.9.x will be supported as it uses a completely different transport
-system.**
-
#### SockJS
SockJS is a real-time server that focuses on cross-domain connections and does
View
@@ -77,14 +77,12 @@
"faye-websocket": "0.11.x",
"mocha": "2.5.x",
"pre-commit": "1.1.x",
- "primus-socket.io-client": "2.0.x",
"pumpify": "1.3.x",
"querystringify": "0.0.x",
"recovery": "0.2.x",
"request": "2.72.x",
"rocambole": "0.7.x",
"rocambole-node-remove": "1.0.x",
- "socket.io": "0.9.x",
"sockjs": "0.3.x",
"sockjs-client": "1.1.x",
"through2": "2.0.x",
@@ -1,3 +0,0 @@
-'use strict';
-
-require('./transformer.base')('Socket.IO');
View
@@ -7,10 +7,6 @@
"server": "engine.io",
"client": "engine.io-client"
},
- "socket.io": {
- "server": "socket.io",
- "client": "primus-socket.io-client"
- },
"browserchannel": {
"server": "browserchannel",
"client": "browserchannel"
@@ -1,113 +0,0 @@
-'use strict';
-/*globals io*/
-
-/**
- * Minimum viable Socket.IO client. This function is stringified and added
- * in our client-side library.
- *
- * @runat client
- * @api private
- */
-module.exports = function client() {
- var ondisconnect = this.emits('incoming::end')
- , onconnect = this.emits('incoming::open')
- , onmessage = this.emits('incoming::data')
- , onerror = this.emits('incoming::error')
- , primus = this
- , socket;
-
- //
- // Select an available Socket.IO factory.
- //
- var factory = (function factory() {
- if ('undefined' !== typeof io && io.Socket) return io;
-
- try { return Primus.requires('primus-socket.io-client'); }
- catch (e) {
- try { return Primus.requires('socket.io-client'); }
- catch (e) {}
- }
-
- return undefined;
- })();
-
- if (!factory) return primus.critical(new Error(
- 'Missing required `primus-socket.io-client` or `socket.io-client` module. ' +
- 'Please run `npm i primus-socket.io-client --save` or ' +
- '`npm i socket.io-client@0.9.x --save`'
- ));
-
- //
- // Connect to the given URL.
- //
- primus.on('outgoing::open', function open() {
- primus.emit('outgoing::end');
-
- var transports = factory.transports
- , Socket = factory.Socket;
-
- if (primus.AVOID_WEBSOCKETS) {
- transports = transports.join(',').replace(/\,?websocket\,?/gim, '').split(',');
- }
-
- //
- // We need to directly use the parsed URL details here to generate the
- // correct urls for Socket.IO to use.
- //
- primus.socket = socket = (new Socket(primus.merge(primus.transport,
- primus.url, {
- host: primus.url.hostname
- }, primus.uri({ protocol: 'http:', query: true, object: true }), {
- 'resource': primus.pathname.slice(1),
- 'force new connection': true,
- 'flash policy port': 843,
- 'transports': transports,
- 'reconnect': false
- }))).of(''); // Force namespace
-
- //
- // Setup the Event handlers.
- //
- socket.on('disconnect', ondisconnect);
- socket.on('connect_failed', onerror);
- socket.on('connect', onconnect);
- socket.on('message', onmessage);
- socket.on('error', onerror);
- });
-
- //
- // We need to write a new message to the socket.
- //
- primus.on('outgoing::data', function write(message) {
- if (socket) socket.send(message);
- });
-
- //
- // Attempt to reconnect the socket.
- //
- primus.on('outgoing::reconnect', function reconnect() {
- primus.emit('outgoing::open');
- });
-
- //
- // We need to close the socket. Bypass the namespaces and disconnect using
- // socket.socket.
- //
- primus.on('outgoing::end', function close() {
- if (!socket) return;
-
- socket.removeListener('disconnect', ondisconnect);
- socket.removeListener('connect_failed', onerror);
- socket.removeListener('connect', onconnect);
- socket.removeListener('message', onmessage);
- socket.removeListener('error', onerror);
-
- //
- // This method can throw an error if it failed to connect to the server.
- //
- try { socket.socket.disconnect(); }
- catch (e) {}
-
- socket = null;
- });
-};
@@ -1,15 +0,0 @@
-'use strict';
-
-//
-// Expose the module as new Transformer instance.
-//
-module.exports = require('../../transformer').extend({
- // Creating a new real-time server.
- server: require('./server'),
-
- // The client-logic to connect with the a server.
- client: require('./client'),
-
- // The client-side library of socket.io.
- library: require('fs').readFileSync(__dirname + '/library.js', 'utf-8')
-});
Oops, something went wrong.

0 comments on commit aa0ae57

Please sign in to comment.