Otherwise, this is set on the prototype and shared across instances :/
Note the change to the test that highlights this bug. A proxy pair was
already created when an earlier test called `beginWebRTC()` but a new
Snowflake instance should start with an empty array.
The binaryType can be "arraybuffer" or "blob", and "blob" is the
default. The code is only aware of "arraybuffer": I discovered a problem
while running snowflake.html in debug mode; this code fails:
if DEBUG
# Go sends only raw bytes...
if '[object ArrayBuffer]' == recv.toString()
bytes = new Uint8Array recv
line = String.fromCharCode.apply(null, bytes)
line = line.trim()
log 'WebRTC --> websocket data: ' + line
with the error:
TypeError: line.trim is not a function[Learn More] snowflake.js:497:16
because recv is of type Blob, not ArrayBuffer.
Despite the unexpected type, the code seemed to work as expected when
not in debug mode. Though the two types provide different interfaces,
they are both valid to pass on to WebSocket.send. The only other thing
we did with it was try to read the .length member for rate-limiting
purposes:
@rateLimit.update chunk.length
but .length is incorrect for either type: Blob uses .size and
ArrayBuffer uses .byteLength. It worked anyway, because
DummyRateLimit.update doesn't actually look at its argument.
We were already setting binaryType="arraybuffer" for WebSocket
connections.