socketstream/socketstream — Issue #151: Raw websocket messages are bloated by slashes
Author: nponeccop
Created: 2012-02-17 11:57:50+00:00
State: open

Here is a beginning of Wireshark capture of a message:

```
5:::{"name":"message","args":["eventВ§{\"t\":\"all\",\"e\":\"collect\",\"p\"
```

The whole protocol stack looks like:

```
Physical
Ethernet
IP
TCP
Websocket
Socket.IO
SocketStream
```

My fragment shows frames or two highest level protocol layers : socket.io frame and Socketstream frame. According to https://github.com/LearnBoost/socket.io-spec , it is an `Event` message (type `5`) with an empty `message id` and an empty `endpoint`.

The `JSON encoded event` is the following:

```
{
name : 'message`
, args : [
bloated_string
]
}
```

There are two efficiency problems with this:

1. There are 6 ids here: message id (empty), endpoint (empty), name ( 'message'), `event` (prefix of `bloated_string`), `t` and `e` (in the JSON object after the `event` prefix.
2. The string with `event` prefix is JSON-encoded twice, so unnecessary slashes bloat the data transferred over network.

The second problem seems to be related with `JSON.stringify` and `JSON.parse` calls in src\websocket\responders\rpc\client.coffee .and server.coffee . What do you think?