write (buffer) {
    // If there is a pending queue, push this on that queue. This means
    // we are not yet connected, so we queue things locally.
    if (this._pending !== null) {
      this._pending.push(buffer)
    } else if (buffer instanceof ChannelBuffer) {
      try {
        this._ws.send(buffer._buffer)
      } catch (error) {
        if (this._ws.readyState !== WS_OPEN) {
          // Websocket has been closed
          this._handleConnectionError()
        } else {
          // Some other error occured
          throw error
        }
      }
    } else {
      throw newError("Don't know how to send buffer: " + buffer)
    }
  }
Write the passed in buffer to connection
@param {ChannelBuffer} buffer - Buffer to write