Fix web-socket-js: encode sent data across FABridge.
This commit is contained in:
parent
af6b17ce06
commit
d38406e6b5
|
@ -104,14 +104,14 @@ public class WebSocket extends EventDispatcher {
|
||||||
public function send(data:String):int {
|
public function send(data:String):int {
|
||||||
if (readyState == OPEN) {
|
if (readyState == OPEN) {
|
||||||
socket.writeByte(0x00);
|
socket.writeByte(0x00);
|
||||||
socket.writeUTFBytes(data);
|
socket.writeUTFBytes(decodeURIComponent(data));
|
||||||
socket.writeByte(0xff);
|
socket.writeByte(0xff);
|
||||||
socket.flush();
|
socket.flush();
|
||||||
main.log("sent: " + data);
|
main.log("sent: " + data);
|
||||||
return -1;
|
return -1;
|
||||||
} else if (readyState == CLOSED) {
|
} else if (readyState == CLOSED) {
|
||||||
var bytes:ByteArray = new ByteArray();
|
var bytes:ByteArray = new ByteArray();
|
||||||
bytes.writeUTFBytes(data);
|
bytes.writeUTFBytes(decodeURIComponent(data));
|
||||||
bufferedAmount += bytes.length; // not sure whether it should include \x00 and \xff
|
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
|
// We use return value to let caller know bufferedAmount because we cannot fire
|
||||||
// stateChange event here which causes weird error:
|
// stateChange event here which causes weird error:
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
if (!this.__flash || this.readyState == WebSocket.CONNECTING) {
|
if (!this.__flash || this.readyState == WebSocket.CONNECTING) {
|
||||||
throw "INVALID_STATE_ERR: Web Socket connection has not been established";
|
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
|
if (result < 0) { // success
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue