mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
Broadcast an event right before and after doing the WebSocket handshake
(imported from commit 29b80c3b72a2f98c25b59dca3d1597cc5e5f2605)
This commit is contained in:
@@ -144,6 +144,9 @@ Socket.prototype = {
|
||||
blueslip.info("Socket connected.");
|
||||
that._is_open = true;
|
||||
|
||||
// Notify listeners that we've finished the websocket handshake
|
||||
$(document).trigger($.Event('websocket_postopen.zulip', {}));
|
||||
|
||||
// We can only authenticate after the DOM has loaded because we need
|
||||
// the CSRF token
|
||||
$(function () {
|
||||
@@ -197,6 +200,9 @@ Socket.prototype = {
|
||||
if (that._is_unloading) {
|
||||
return;
|
||||
}
|
||||
// We've failed to handshake, but notify that the attempt finished
|
||||
$(document).trigger($.Event('websocket_postopen.zulip', {}));
|
||||
|
||||
blueslip.info("SockJS connection lost. Attempting to reconnect soon.");
|
||||
that._connection_failures++;
|
||||
that._is_reconnecting = false;
|
||||
|
||||
@@ -1211,6 +1211,10 @@ var WebSocketTransport = SockJS.websocket = function(ri, trans_url) {
|
||||
that.url = url;
|
||||
var Constructor = _window.WebSocket || _window.MozWebSocket;
|
||||
|
||||
// Zulip Addition: Notify that we're about to start the
|
||||
// WebSocket handshake
|
||||
$(document).trigger($.Event('websocket_preopen.zulip', {}));
|
||||
|
||||
that.ws = new Constructor(that.url);
|
||||
that.ws.onmessage = function(e) {
|
||||
that.ri._didMessage(e.data);
|
||||
|
||||
Reference in New Issue
Block a user