(data, binary)
| 13 | const PROTOCOL_VERSION = 2; |
| 14 | |
| 15 | function parseMessage(data, binary) { |
| 16 | if (binary) { |
| 17 | console.error('Expected text message, got binary!'); |
| 18 | return undefined; |
| 19 | } |
| 20 | try { |
| 21 | const message = JSON.parse(data); |
| 22 | if (message.version === PROTOCOL_VERSION) { |
| 23 | return message; |
| 24 | } |
| 25 | console.error('Received message had wrong protocol version: ' |
| 26 | + message.version); |
| 27 | } catch (e) { |
| 28 | console.error('Failed to parse the message as JSON:\n' + data); |
| 29 | } |
| 30 | return undefined; |
| 31 | } |
| 32 | |
| 33 | function isBroadcast(message) { |
| 34 | return ( |
no test coverage detected
searching dependent graphs…