-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.txt
81 lines (70 loc) · 2.49 KB
/
server.txt
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
Take the buffer and read the first 8 bits or first byte
firstByte = buffer.readUInt8(0)
>>> always results in non-negative
returns an unsigned 32-bit integer
Shift firstByte to the right by 7 bits
firstByte (10000000) >>> 7 (00000111)
We're only interested in the farthest
right bit and therefore we are using a
bitwise & with 1 to get the farthest
right bit value
10000000
00001111
*/
// Not used now, but place holder
// switch(opCode) {
// case constants.CONTINUATION_FRAME:
// // Non-control
// console.log('continuation frame');
// break;
// case constants.TEXT_FRAME: // They have `opCode !== 0x01` for this
// // Non-control
// console.log('text frame');
// break;
// case constants.BINARY_FRAME:
// // Non-control
// console.log('binary frame');
// break;
// // reserved for further non-control frames
// case constants.NONCONTROL_FRAME_3:
// case constants.NONCONTROL_FRAME_4:
// case constants.NONCONTROL_FRAME_5:
// case constants.NONCONTROL_FRAME_6:
// case constants.NONCONTROL_FRAME_7:
// console.log('further non-control frames');
// break;
// // denotes a connection close
// case constants.CONNECTION_CLOSE:
// // Control
// console.log('connection close');
// return null;
// break;
// // denotes a ping
// case constants.PING:
// // Control
// console.log('ping');
// break;
// // denotes a pong
// case constants.PONG:
// // Control
// console.log('pong');
// break;
// case constants.CONTROL_FRAME_B:
// case constants.CONTROL_FRAME_C:
// case constants.CONTROL_FRAME_D:
// case constants.CONTROL_FRAME_E:
// case constants.CONTROL_FRAME_F:
// // Reserved for further control frames.
// console.log('further non-control frames');
// break;
// default:
// return null;
// }
/*
We are only interested in the Payload Length and
therefore have a 0 for the MASK
01111111 (0x7F -> 127)
*/
// we were already reading data in a BE type of way from left to right. Why
// didn't we do the same on line 47?