Fix race when determining and setting message type
This fixes a race.
However, I'm unsure of the original codes intent, because it seems odd that the message type should be allowed to fluctuate between sends and receives like this.
Looking at the terminal client source code, binaryType = arraybuffer
is used, which I think always encodes as binary frames. It then uses utf8 encoding/decoding on top of that. It's likely that the message type should just always be binary. This probably needs some additional investigation, but for now, the code stays the same, with just the race fix.
Edited by Arran Walker