Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / socket.io-client / README.md
1 socket.io
2 =========
3
4 #### Sockets for the rest of us
5
6 The `socket.io` client is basically a simple HTTP Socket interface implementation.
7 It looks similar to WebSocket while providing additional features and
8 leveraging other transports when WebSocket is not supported by the user's
9 browser.
10
11 ```js
12 var socket = io.connect('http://domain.com');
13 socket.on('connect', function () {
14   // socket connected
15 });
16 socket.on('custom event', function () {
17   // server emitted a custom event
18 });
19 socket.on('disconnect', function () {
20   // socket disconnected
21 });
22 socket.send('hi there');
23 ```
24
25 ### Recipes
26
27 #### Utilizing namespaces (ie: multiple sockets)
28
29 If you want to namespace all the messages and events emitted to a particular
30 endpoint, simply specify it as part of the `connect` uri:
31
32 ```js
33 var chat = io.connect('http://localhost/chat');
34 chat.on('connect', function () {
35   // chat socket connected
36 });
37
38 var news = io.connect('/news'); // io.connect auto-detects host
39 news.on('connect', function () {
40   // news socket connected
41 });
42 ```
43
44 #### Emitting custom events
45
46 To ease with the creation of applications, you can emit custom events outside
47 of the global `message` event.
48
49 ```js
50 var socket = io.connect();
51 socket.emit('server custom event', { my: 'data' });
52 ```
53
54 #### Forcing disconnection
55
56 ```js
57 var socket = io.connect();
58 socket.on('connect', function () {
59   socket.disconnect();
60 });
61 ```
62
63 ### Documentation 
64
65 #### io#connect
66
67 ```js
68 io.connect(uri, [options]);
69 ```
70
71 ##### Options:
72
73 - *resource*
74
75     socket.io
76
77   The resource is what allows the `socket.io` server to identify incoming connections by `socket.io` clients. In other words, any HTTP server can implement socket.io and still serve other normal, non-realtime HTTP requests.
78
79 - *transports*
80
81 ```js
82 ['websocket', 'flashsocket', 'htmlfile', 'xhr-multipart', 'xhr-polling', 'jsonp-polling']
83 ```
84
85   A list of the transports to attempt to utilize (in order of preference).
86
87 - *'connect timeout'*
88
89 ```js
90 5000
91 ```
92
93   The amount of milliseconds a transport has to create a connection before we consider it timed out.
94   
95 - *'try multiple transports'*
96
97 ```js
98 true
99 ```
100
101   A boolean indicating if we should try other transports when the  connectTimeout occurs.
102   
103 - *reconnect*
104
105 ```js
106 true
107 ```
108
109   A boolean indicating if we should automatically reconnect if a connection is disconnected. 
110   
111 - *'reconnection delay'*
112
113 ```js
114 500
115 ```
116
117   The amount of milliseconds before we try to connect to the server again. We are using a exponential back off algorithm for the following reconnections, on each reconnect attempt this value will get multiplied (500 > 1000 > 2000 > 4000 > 8000).
118   
119
120 - *'max reconnection attempts'*
121
122 ```js
123 10
124 ```
125
126   The amount of attempts should we make using the current transport to connect to the server? After this we will do one final attempt, and re-try with all enabled transport methods before we give up.
127
128 ##### Properties:
129
130 - *options*
131
132   The passed in options combined with the defaults.
133
134 - *connected*
135
136   Whether the socket is connected or not.
137   
138 - *connecting*
139
140   Whether the socket is connecting or not.
141
142 - *reconnecting*
143
144   Whether we are reconnecting or not.
145   
146 - *transport*  
147
148   The transport instance.
149
150 ##### Methods:
151   
152 - *connect(λ)*
153
154   Establishes a connection. If λ is supplied as argument, it will be called once the connection is established.
155   
156 - *send(message)*
157   
158   A string of data to send.
159   
160 - *disconnect*
161
162   Closes the connection.
163   
164 - *on(event, λ)*
165
166   Adds a listener for the event *event*.
167
168 - *once(event, λ)*
169
170   Adds a one time listener for the event *event*. The listener is removed after the first time the event is fired.
171   
172 - *removeListener(event, λ)*
173
174   Removes the listener λ for the event *event*.
175   
176 ##### Events:
177
178 - *connect*
179
180   Fired when the connection is established and the handshake successful.
181   
182 - *connecting(transport_type)*
183
184     Fired when a connection is attempted, passing the transport name.
185   
186 - *connect_failed*
187
188     Fired when the connection timeout occurs after the last connection attempt.
189   This only fires if the `connectTimeout` option is set.
190   If the `tryTransportsOnConnectTimeout` option is set, this only fires once all
191   possible transports have been tried.
192   
193 - *message(message)*
194   
195   Fired when a message arrives from the server
196
197 - *close*
198
199   Fired when the connection is closed. Be careful with using this event, as some transports will fire it even under temporary, expected disconnections (such as XHR-Polling).
200   
201 - *disconnect*
202
203   Fired when the connection is considered disconnected.
204   
205 - *reconnect(transport_type,reconnectionAttempts)*
206
207   Fired when the connection has been re-established. This only fires if the `reconnect` option is set.
208
209 - *reconnecting(reconnectionDelay,reconnectionAttempts)*
210
211   Fired when a reconnection is attempted, passing the next delay for the next reconnection.
212
213 - *reconnect_failed*
214
215   Fired when all reconnection attempts have failed and we where unsuccessful in reconnecting to the server.  
216
217 ### Contributors
218
219 Guillermo Rauch <guillermo@learnboost.com>
220
221 Arnout Kazemier <info@3rd-eden.com>
222
223 ### License 
224
225 (The MIT License)
226
227 Copyright (c) 2010 LearnBoost <dev@learnboost.com>
228
229 Permission is hereby granted, free of charge, to any person obtaining
230 a copy of this software and associated documentation files (the
231 'Software'), to deal in the Software without restriction, including
232 without limitation the rights to use, copy, modify, merge, publish,
233 distribute, sublicense, and/or sell copies of the Software, and to
234 permit persons to whom the Software is furnished to do so, subject to
235 the following conditions:
236
237 The above copyright notice and this permission notice shall be
238 included in all copies or substantial portions of the Software.
239
240 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
241 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
242 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
243 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
244 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
245 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
246 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.