├── .gitignore ├── .npm └── package │ ├── .gitignore │ ├── README │ └── npm-shrinkwrap.json ├── .versions ├── README.md ├── package.js ├── socket-io-client-tests.js ├── socket-io-client.js └── versions.json /.gitignore: -------------------------------------------------------------------------------- 1 | .build* 2 | -------------------------------------------------------------------------------- /.npm/package/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.npm/package/README: -------------------------------------------------------------------------------- 1 | This directory and the files immediately inside it are automatically generated 2 | when you change this package's NPM dependencies. Commit the files in this 3 | directory (npm-shrinkwrap.json, .gitignore, and this README) to source control 4 | so that others run the same versions of sub-dependencies. 5 | 6 | You should NOT check in the node_modules directory that Meteor automatically 7 | creates; if you are using git, the .gitignore file tells git to ignore it. 8 | -------------------------------------------------------------------------------- /.npm/package/npm-shrinkwrap.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "socket.io-client": { 4 | "version": "1.2.0", 5 | "dependencies": { 6 | "debug": { 7 | "version": "0.7.4" 8 | }, 9 | "engine.io-client": { 10 | "version": "1.4.2", 11 | "dependencies": { 12 | "has-cors": { 13 | "version": "1.0.3", 14 | "dependencies": { 15 | "global": { 16 | "version": "https://github.com/component/global/archive/v2.0.1.tar.gz" 17 | } 18 | } 19 | }, 20 | "ws": { 21 | "version": "0.4.31", 22 | "dependencies": { 23 | "commander": { 24 | "version": "0.6.1" 25 | }, 26 | "nan": { 27 | "version": "0.3.2" 28 | }, 29 | "tinycolor": { 30 | "version": "0.0.1" 31 | }, 32 | "options": { 33 | "version": "0.0.6" 34 | } 35 | } 36 | }, 37 | "xmlhttprequest": { 38 | "version": "https://github.com/LearnBoost/node-XMLHttpRequest/archive/0f36d0b5ebc03d85f860d42a64ae9791e1daa433.tar.gz" 39 | }, 40 | "engine.io-parser": { 41 | "version": "1.1.0", 42 | "dependencies": { 43 | "base64-arraybuffer": { 44 | "version": "0.1.2" 45 | }, 46 | "after": { 47 | "version": "0.8.1" 48 | }, 49 | "arraybuffer.slice": { 50 | "version": "0.0.6" 51 | }, 52 | "blob": { 53 | "version": "0.0.2" 54 | }, 55 | "utf8": { 56 | "version": "2.0.0" 57 | } 58 | } 59 | }, 60 | "parseuri": { 61 | "version": "0.0.4", 62 | "dependencies": { 63 | "better-assert": { 64 | "version": "1.0.1", 65 | "dependencies": { 66 | "callsite": { 67 | "version": "1.0.0" 68 | } 69 | } 70 | } 71 | } 72 | }, 73 | "parsejson": { 74 | "version": "0.0.1", 75 | "dependencies": { 76 | "better-assert": { 77 | "version": "1.0.1", 78 | "dependencies": { 79 | "callsite": { 80 | "version": "1.0.0" 81 | } 82 | } 83 | } 84 | } 85 | }, 86 | "parseqs": { 87 | "version": "0.0.2", 88 | "dependencies": { 89 | "better-assert": { 90 | "version": "1.0.1", 91 | "dependencies": { 92 | "callsite": { 93 | "version": "1.0.0" 94 | } 95 | } 96 | } 97 | } 98 | }, 99 | "component-inherit": { 100 | "version": "0.0.3" 101 | } 102 | } 103 | }, 104 | "component-bind": { 105 | "version": "1.0.0" 106 | }, 107 | "component-emitter": { 108 | "version": "1.1.2" 109 | }, 110 | "object-component": { 111 | "version": "0.0.3" 112 | }, 113 | "socket.io-parser": { 114 | "version": "2.2.2", 115 | "dependencies": { 116 | "json3": { 117 | "version": "3.2.6" 118 | }, 119 | "isarray": { 120 | "version": "0.0.1" 121 | }, 122 | "benchmark": { 123 | "version": "1.0.0" 124 | } 125 | } 126 | }, 127 | "has-binary": { 128 | "version": "0.1.5", 129 | "dependencies": { 130 | "isarray": { 131 | "version": "0.0.1" 132 | } 133 | } 134 | }, 135 | "indexof": { 136 | "version": "0.0.1" 137 | }, 138 | "parseuri": { 139 | "version": "0.0.2", 140 | "dependencies": { 141 | "better-assert": { 142 | "version": "1.0.1", 143 | "dependencies": { 144 | "callsite": { 145 | "version": "1.0.0" 146 | } 147 | } 148 | } 149 | } 150 | }, 151 | "to-array": { 152 | "version": "0.1.3" 153 | } 154 | } 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /.versions: -------------------------------------------------------------------------------- 1 | base64@1.0.3 2 | binary-heap@1.0.3 3 | callback-hook@1.0.3 4 | check@1.0.5 5 | ddp@1.1.0 6 | ejson@1.0.6 7 | geojson-utils@1.0.3 8 | id-map@1.0.3 9 | joncursi:socket-io-client@0.1.3 10 | json@1.0.3 11 | local-test:joncursi:socket-io-client@0.1.3 12 | logging@1.0.7 13 | meteor@1.1.6 14 | minimongo@1.0.8 15 | mongo@1.1.0 16 | ordered-dict@1.0.3 17 | random@1.0.3 18 | retry@1.0.3 19 | tinytest@1.0.5 20 | tracker@1.0.7 21 | underscore@1.0.3 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # socket-io-client 2 | A Meteor wrapper for the npm [socket.io-client](https://www.npmjs.org/package/socket.io-client) binary package. 3 | 4 | ## Meteor 1.3+ 5 | Meteor 1.3+ projects should install [Socket IO](https://www.npmjs.com/package/socket.io-client) directly from npm instead of using this package. 6 | 7 | ``` 8 | meteor npm install --save socket.io-client 9 | ``` 10 | 11 | For more information, refer to the [Meteor Guide](http://guide.meteor.com/1.3-migration.html#packages) 12 | 13 | ## Pre Meteor 1.3 14 | 15 | ### Purpose 16 | This package enables the Meteor server to communicate with an external server over a socket.io connection. Once a the connection is established to the external server, the Meteor server behaves as the client and receives the data stream. 17 | 18 | ### Usage 19 | This package exposes a global variable `io` on the Meteor server in order to establish a websocket connection. Example usage: 20 | 21 | ```javascript 22 | // server/file.js 23 | 24 | // define the websocket connection using the `io` global variable 25 | var socket = io('https://path-to-external-server-goes-here/'); 26 | 27 | // subscribe to a data feed 28 | socket.emit('subscribe', 'data-feed-name-goes-here'); 29 | 30 | // we can now handle connect, disconnect, and data-driven events 31 | // NOTE: you must open up a new fiber using Meteor.bindEnvironment 32 | // in order to perform Mongo read/writes or call Meteor methods 33 | // within the socket connection 34 | 35 | // on connect 36 | socket.on('connect', Meteor.bindEnvironment(function() { 37 | console.log('Connected to the websocket!'); 38 | Meteor.call('methodName1'); 39 | 40 | // on data event 41 | socket.on('data-event', Meteor.bindEnvironment(function(data) { 42 | console.log(data); 43 | Meteor.call('methodName2'); 44 | }, function(e) { 45 | throw e; 46 | })); 47 | 48 | // on disconnect 49 | socket.on('disconnect', Meteor.bindEnvironment(function() { 50 | console.log('Disconnected from the websocket!'); 51 | Meteor.call('methodName3'); 52 | }, function(e) { 53 | throw e; 54 | })); 55 | 56 | }, function(e) { 57 | throw e; 58 | })); 59 | ``` 60 | 61 | ### Supported Architectures 62 | This binary package is compiled with [Meteor Build](https://www.meteor.com/services/build) and should work on all four of the officially supported Meteor architectures: 63 | - OS X (`os.osx.x86_64`) 64 | - Linux on 64-bit Intel (`os.linux.x86_64`) 65 | - Linux on 32-bit Intel (`os.linux.x86_32`) 66 | - Windows (`os.windows.x86_32`) 67 | -------------------------------------------------------------------------------- /package.js: -------------------------------------------------------------------------------- 1 | Package.describe({ 2 | name: 'joncursi:socket-io-client', 3 | summary: 'A Meteor package wrapper for the official socket.io-client', 4 | version: '0.1.4', 5 | git: 'https://github.com/joncursi/socket-io-client' 6 | }); 7 | 8 | Npm.depends({ 9 | 'socket.io-client': '1.2.0' 10 | }); 11 | 12 | Package.onUse(function (api, where) { 13 | api.versionsFrom('1.0'); 14 | api.addFiles(['socket-io-client.js'], 'server'); 15 | if (api.export) { 16 | api.export('io'); 17 | } 18 | }); 19 | 20 | Package.onTest(function(api) { 21 | api.use('tinytest'); 22 | api.use('joncursi:socket-io-client'); 23 | api.addFiles('socket-io-client-tests.js'); 24 | }); -------------------------------------------------------------------------------- /socket-io-client-tests.js: -------------------------------------------------------------------------------- 1 | // Write your tests here! 2 | // Here is an example. 3 | Tinytest.add('example', function (test) { 4 | test.equal(true, true); 5 | }); 6 | -------------------------------------------------------------------------------- /socket-io-client.js: -------------------------------------------------------------------------------- 1 | io = Npm.require('socket.io-client'); -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | [ 4 | "meteor", 5 | "1.1.3" 6 | ], 7 | [ 8 | "underscore", 9 | "1.0.1" 10 | ] 11 | ], 12 | "pluginDependencies": [], 13 | "toolVersion": "meteor-tool@1.0.35", 14 | "format": "1.0" 15 | } --------------------------------------------------------------------------------