mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 12:21:58 +00:00
[manual] socket: Send explicit ACKs
There will be browser errors on staging when this is deployed due to the socket protocol changing. (imported from commit f1eda5b5c2ec9c60c23b3ca96277a61debadf5bb)
This commit is contained in:
@@ -127,7 +127,9 @@ Socket.prototype = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
sockjs.onmessage = function Socket__sockjs_onmessage(event) {
|
sockjs.onmessage = function Socket__sockjs_onmessage(event) {
|
||||||
|
if (event.data.type === 'resposne') {
|
||||||
that._process_response(event.data.req_id, event.data.response);
|
that._process_response(event.data.req_id, event.data.response);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sockjs.onheartbeat = function Socket__socjks_onheartbeat() {
|
sockjs.onheartbeat = function Socket__socjks_onheartbeat() {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class SocketConnection(sockjs.tornado.SockJSConnection):
|
|||||||
|
|
||||||
def authenticate_client(self, msg):
|
def authenticate_client(self, msg):
|
||||||
if self.authenticated:
|
if self.authenticated:
|
||||||
self.session.send_message({'req_id': msg['req_id'],
|
self.session.send_message({'req_id': msg['req_id'], 'type': 'response',
|
||||||
'response': {'result': 'error', 'msg': 'Already authenticated'}})
|
'response': {'result': 'error', 'msg': 'Already authenticated'}})
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -122,7 +122,8 @@ class SocketConnection(sockjs.tornado.SockJSConnection):
|
|||||||
self.authenticated = True
|
self.authenticated = True
|
||||||
register_connection(queue_id, self)
|
register_connection(queue_id, self)
|
||||||
|
|
||||||
response = {'req_id': msg['req_id'], 'response': {'result': 'success', 'msg': ''}}
|
response = {'req_id': msg['req_id'], 'type': 'response',
|
||||||
|
'response': {'result': 'success', 'msg': ''}}
|
||||||
|
|
||||||
status_inquiries = msg['request'].get('status_inquiries')
|
status_inquiries = msg['request'].get('status_inquiries')
|
||||||
if status_inquiries is not None:
|
if status_inquiries is not None:
|
||||||
@@ -145,6 +146,8 @@ class SocketConnection(sockjs.tornado.SockJSConnection):
|
|||||||
record_request_start_data(log_data)
|
record_request_start_data(log_data)
|
||||||
msg = ujson.loads(msg)
|
msg = ujson.loads(msg)
|
||||||
|
|
||||||
|
self.session.send_message({'req_id': msg['req_id'], 'type': 'ack'});
|
||||||
|
|
||||||
if msg['type'] == 'auth':
|
if msg['type'] == 'auth':
|
||||||
log_data['extra'] += ']'
|
log_data['extra'] += ']'
|
||||||
try:
|
try:
|
||||||
@@ -156,7 +159,8 @@ class SocketConnection(sockjs.tornado.SockJSConnection):
|
|||||||
client_name='?')
|
client_name='?')
|
||||||
except SocketAuthError as e:
|
except SocketAuthError as e:
|
||||||
response = {'result': 'error', 'msg': e.msg}
|
response = {'result': 'error', 'msg': e.msg}
|
||||||
self.session.send_message({'req_id': msg['req_id'], 'response': response})
|
self.session.send_message({'req_id': msg['req_id'], 'type': 'response',
|
||||||
|
'response': response})
|
||||||
write_log_line(log_data, path='/socket/auth', method='SOCKET',
|
write_log_line(log_data, path='/socket/auth', method='SOCKET',
|
||||||
remote_ip=self.session.conn_info.ip,
|
remote_ip=self.session.conn_info.ip,
|
||||||
email='unknown', client_name='?',
|
email='unknown', client_name='?',
|
||||||
@@ -165,7 +169,8 @@ class SocketConnection(sockjs.tornado.SockJSConnection):
|
|||||||
else:
|
else:
|
||||||
if not self.authenticated:
|
if not self.authenticated:
|
||||||
response = {'result': 'error', 'msg': "Not yet authenticated"}
|
response = {'result': 'error', 'msg': "Not yet authenticated"}
|
||||||
self.session.send_message({'req_id': msg['req_id'], 'response': response})
|
self.session.send_message({'req_id': msg['req_id'], 'type': 'response',
|
||||||
|
'response': response})
|
||||||
write_log_line(log_data, path='/socket/service_request', method='SOCKET',
|
write_log_line(log_data, path='/socket/service_request', method='SOCKET',
|
||||||
remote_ip=self.session.conn_info.ip,
|
remote_ip=self.session.conn_info.ip,
|
||||||
email='unknown', client_name='?',
|
email='unknown', client_name='?',
|
||||||
@@ -240,7 +245,8 @@ def respond_send_message(data):
|
|||||||
|
|
||||||
connection = get_connection(data['server_meta']['client_id'])
|
connection = get_connection(data['server_meta']['client_id'])
|
||||||
if connection is not None:
|
if connection is not None:
|
||||||
connection.session.send_message({'req_id': data['req_id'], 'response': data['response']})
|
connection.session.send_message({'req_id': data['req_id'], 'type': 'response',
|
||||||
|
'response': data['response']})
|
||||||
|
|
||||||
# TODO: Fill in client name
|
# TODO: Fill in client name
|
||||||
# TODO: Maybe fill in the status code correctly
|
# TODO: Maybe fill in the status code correctly
|
||||||
|
|||||||
Reference in New Issue
Block a user