Commit d38406e6 authored by Joel Martin's avatar Joel Martin

Fix web-socket-js: encode sent data across FABridge.

parent af6b17ce
......@@ -104,14 +104,14 @@ public class WebSocket extends EventDispatcher {
public function send(data:String):int {
if (readyState == OPEN) {
socket.writeByte(0x00);
socket.writeUTFBytes(data);
socket.writeUTFBytes(decodeURIComponent(data));
socket.writeByte(0xff);
socket.flush();
main.log("sent: " + data);
return -1;
} else if (readyState == CLOSED) {
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes(data);
bytes.writeUTFBytes(decodeURIComponent(data));
bufferedAmount += bytes.length; // not sure whether it should include \x00 and \xff
// We use return value to let caller know bufferedAmount because we cannot fire
// stateChange event here which causes weird error:
......
......@@ -86,7 +86,7 @@
if (!this.__flash || this.readyState == WebSocket.CONNECTING) {
throw "INVALID_STATE_ERR: Web Socket connection has not been established";
}
var result = this.__flash.send(data);
var result = this.__flash.send(encodeURIComponent(data));
if (result < 0) { // success
return true;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment