Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 7x 1x 3x 1x 2x 2x 1x 1x 1x 1x | /** * * @param protocol * @param host * @param options * @returns {AbstractWrapper} Instantiated WebSocket/Socket.IO object */ function network (protocol, options) { switch (protocol) { case 'http': return new (require('./protocols/http'))(options); case 'websocket': if (typeof window !== 'undefined' && typeof WebSocket === 'undefined') { throw new Error('Aborting: no websocket support detected.'); } return new (require('./protocols/websocket'))(options); case 'socketio': if (!window.io) { throw new Error('Aborting: no socket.io library loaded.'); } return new (require('./protocols/socketio'))(options); default: throw new Error('Aborting: unknown protocol "' + protocol + '" (only "http", "websocket" and "socketio" are available).'); } } module.exports = network; |