Skip to content

Commit

Permalink
feat: add error listen
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Sep 9, 2022
1 parent b67b869 commit e12b797
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export class WebsocketComponent implements OnInit, OnDestroy {
// * 通过 SocketIO 通知后端
this.socket = io(APP_CONFIG.SOCKETIO_URL, { transports: ['websocket'] });
this.socket.on('connect_error', (error) => {
// * conncet socketIO is failed
console.log('connect_error', error);
this.isSocketConnect = false;
});
this.socket.on('error', (error) => {
// * conncet socketIO is failed
console.log('error', error);
this.isSocketConnect = false;
Expand Down Expand Up @@ -229,7 +234,11 @@ export class WebsocketComponent implements OnInit, OnDestroy {
}
this.model.response.responseBody.unshift({ type: 'get', msg: content, isExpand: false });
} else {
this.model.response.responseBody.unshift({ type: 'end', msg: `Disconnect by ${this.getLink()}` , isExpand: false });
this.model.response.responseBody.unshift({
type: 'end',
msg: `Disconnect by ${this.getLink()}`,
isExpand: false,
});
this.wsStatus = 'disconnect';
this.switchEditStatus();
this.unListen();
Expand Down

0 comments on commit e12b797

Please sign in to comment.