root / HServer / 00.Server / 00.Program / node_modules / socket.io-client / README.md
이력 | 보기 | 이력해설 | 다운로드 (1.93 KB)
1 | 39 | HKM | |
---|---|---|---|
2 | # socket.io-client |
||
3 | |||
4 | [](http://travis-ci.org/socketio/socket.io-client) |
||
5 | [](https://david-dm.org/socketio/socket.io-client) |
||
6 | [](https://david-dm.org/socketio/socket.io-client#info=devDependencies) |
||
7 |  |
||
8 |  |
||
9 | [](http://slack.socket.io) |
||
10 | |||
11 | [](https://saucelabs.com/u/socket) |
||
12 | |||
13 | ## How to use |
||
14 | |||
15 | A standalone build of `socket.io-client` is exposed automatically by the |
||
16 | socket.io server as `/socket.io/socket.io.js`. Alternatively you can |
||
17 | serve the file `socket.io.js` found in the `dist` folder. |
||
18 | |||
19 | ```html |
||
20 | <script src="/socket.io/socket.io.js"></script> |
||
21 | <script> |
||
22 | var socket = io('http://localhost'); |
||
23 | socket.on('connect', function(){}); |
||
24 | socket.on('event', function(data){}); |
||
25 | socket.on('disconnect', function(){}); |
||
26 | </script> |
||
27 | ``` |
||
28 | |||
29 | ```js |
||
30 | // with ES6 import |
||
31 | import io from 'socket.io-client'; |
||
32 | |||
33 | const socket = io('http://localhost'); |
||
34 | ``` |
||
35 | |||
36 | A slim build (without `JSON3`, a JSON polyfill for IE6/IE7, and `debug`) is also available: `socket.io.slim.js`. |
||
37 | |||
38 | Socket.IO is compatible with [browserify](http://browserify.org/) and [webpack](https://webpack.js.org/) (see example [there](https://github.com/socketio/socket.io/tree/2.0.3/examples/webpack-build)). |
||
39 | |||
40 | ### Node.JS (server-side usage) |
||
41 | |||
42 | Add `socket.io-client` to your `package.json` and then: |
||
43 | |||
44 | ```js |
||
45 | var socket = require('socket.io-client')('http://localhost'); |
||
46 | socket.on('connect', function(){}); |
||
47 | socket.on('event', function(data){}); |
||
48 | socket.on('disconnect', function(){}); |
||
49 | ``` |
||
50 | |||
51 | ## API |
||
52 | |||
53 | See [API](/docs/API.md) |
||
54 | |||
55 | ## License |
||
56 | |||
57 | [MIT](/LICENSE) |