@@ -10,6 +10,8 @@ Table of Contents:
10
10
11
11
- [ Revision] ( #revision )
12
12
- [ Anatomy of an Engine.IO session] ( #anatomy-of-an-engineio-session )
13
+ - [ Sample session] ( #sample-session )
14
+ - [ Sample session with WebSocket only] ( #sample-session-with-websocket-only )
13
15
- [ URLs] ( #urls )
14
16
- [ Encoding] ( #encoding )
15
17
- [ Packet] ( #packet )
@@ -55,25 +57,7 @@ with `pong` packets.
55
57
5 . Polling transports can send a ` close ` packet to close the socket, since
56
58
they're expected to be "opening" and "closing" all the time.
57
59
58
- Example with WebSocket connection:
59
-
60
- ```
61
- GET /engine.io/?EIO=4&transport=websocket&sid=lv_VI97HAXpY6yYWAAAC
62
- < HTTP/1.1 101 Switching Protocols
63
- ```
64
-
65
- WebSocket frames:
66
-
67
- ```
68
- < 0{"sid":"lv_VI97HAXpY6yYWAAAC","pingInterval":25000,"pingTimeout":5000} => handshake
69
- > 4hello => message (not concatenated)
70
- > 4world
71
- < 2 => "ping" packet type
72
- > 3 => "pong" packet type
73
- > 1 => "close" packet type
74
- ```
75
-
76
- Example with polling:
60
+ ### Sample session
77
61
78
62
- Request n°1 (open packet)
79
63
@@ -91,8 +75,12 @@ Details:
91
75
{"sid":... => the handshake data
92
76
```
93
77
78
+ Note: the ` t ` query param is used to ensure that the request is not cached by the browser.
79
+
94
80
- Request n°2 (message in):
95
81
82
+ ` socket.send('hey') ` is executed on the server:
83
+
96
84
```
97
85
GET /engine.io/?EIO=4&transport=polling&t=N8hyd7H&sid=lv_VI97HAXpY6yYWAAAC
98
86
< HTTP/1.1 200 OK
@@ -107,8 +95,12 @@ Details:
107
95
hey => the actual message
108
96
```
109
97
98
+ Note: the ` sid ` query param contains the sid sent in the handshake.
99
+
110
100
- Request n°3 (message out)
111
101
102
+ ` socket.send('hello'); socket.send('world'); ` is executed on the client:
103
+
112
104
```
113
105
POST /engine.io/?EIO=4&transport=polling&t=N8hzxke&sid=lv_VI97HAXpY6yYWAAAC
114
106
> Content-Type: text/plain; charset=UTF-8
@@ -148,6 +140,28 @@ WebSocket frames:
148
140
> 1 => "close" packet type
149
141
```
150
142
143
+ ### Sample session with WebSocket only
144
+
145
+ In that case, the client only enables WebSocket (without HTTP polling).
146
+
147
+ ```
148
+ GET /engine.io/?EIO=4&transport=websocket
149
+ < HTTP/1.1 101 Switching Protocols
150
+ ```
151
+
152
+ WebSocket frames:
153
+
154
+ ```
155
+ < 0{"sid":"lv_VI97HAXpY6yYWAAAC","pingInterval":25000,"pingTimeout":5000} => handshake
156
+ < 4hey
157
+ > 4hello => message (not concatenated)
158
+ > 4world
159
+ < 2 => "ping" packet type
160
+ > 3 => "pong" packet type
161
+ > 1 => "close" packet type
162
+ ```
163
+
164
+
151
165
## URLs
152
166
153
167
An Engine.IO url is composed as follows:
0 commit comments