code: function onmessage(data) {
            if (!handshaked) {
              handshaked = true;
              // The handshake output is in the form of URI.
              var result = url.parse(data, true).query;
              // A newly issued id for HTTP transport. It is used to identify which HTTP transport
              // is associated with which HTTP exchange. Don't confuse it with an id for socket,
              // `cettia-id`.
              self.id = result["cettia-transport-id"];
              // And then fire `open` event.
              self.emit("open");
            } else {
              // `code` is a first character of a message and used to recognize that delivered
              // message is text message or binary message.
              var code = data.substring(0, 1);
              data = data.substring(1);
              switch (code) {
                // If the `code` is `1`, the remainder of message is a plain text message. Fires
                // `text` event.
                case "1":
                  self.emit("text", data);
                  break;
                // If the `code` is `2`, the remainder of message is a Base64-encoded binary
                // message. Decodes it in Base64 and fires `binary` event.
                case "2":
                  self.emit("binary", new Buffer(data, "base64"));
                  break;
                // Otherwise, it is invalid. Fires an error and closes the connection.
                default:
                  self.emit("error", new Error("protocol"));
                  self.close();
                  break;
              }
            }
          }
docs: On a message of the event stream format of Server-Sent Events,