Don't fake open events in Websock
We don't know if the caller is prepared to receive those events right now as normally they would get them on a fresh new stack later. We also can't delay delivery since then we might deliver the event after any pending "message" events. Better to push the problem one layer up to the caller, which now needs to be more aware of the state of the WebSocket object it is trying to use.
This commit is contained in:
@@ -247,7 +247,7 @@ export default class Websock {
|
||||
this._websocket.binaryType = "arraybuffer";
|
||||
this._websocket.onmessage = this._recvMessage.bind(this);
|
||||
|
||||
const onOpen = () => {
|
||||
this._websocket.onopen = () => {
|
||||
Log.Debug('>> WebSock.onopen');
|
||||
if (this._websocket.protocol) {
|
||||
Log.Info("Server choose sub-protocol: " + this._websocket.protocol);
|
||||
@@ -257,12 +257,6 @@ export default class Websock {
|
||||
Log.Debug("<< WebSock.onopen");
|
||||
};
|
||||
|
||||
if (this.readyState === 'open') {
|
||||
onOpen();
|
||||
} else {
|
||||
this._websocket.onopen = onOpen;
|
||||
}
|
||||
|
||||
this._websocket.onclose = (e) => {
|
||||
Log.Debug(">> WebSock.onclose");
|
||||
this._eventHandlers.close(e);
|
||||
|
||||
Reference in New Issue
Block a user