perf: 优化sse连接
This commit is contained in:
parent
029685448f
commit
db2f1fdd93
@ -17,6 +17,13 @@ const throttledConnectSSE = _.throttle((username) => {
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
||||||
function connectToSSE(username) {
|
function connectToSSE(username) {
|
||||||
|
|
||||||
|
if (eventSource) {
|
||||||
|
// 移除之前的事件监听器
|
||||||
|
eventSource.removeEventListener('message', handleMessage);
|
||||||
|
eventSource.removeEventListener('error', handleError.bind(null, username));
|
||||||
|
}
|
||||||
|
|
||||||
const url = `/api/events?username=${username}&uuid=${uuid}`;
|
const url = `/api/events?username=${username}&uuid=${uuid}`;
|
||||||
eventSource = new EventSource(url);
|
eventSource = new EventSource(url);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user