This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 实现一个栈类 | |
| class Stack { | |
| constructor() { | |
| this.items = []; | |
| } | |
| // 入栈 | |
| push(element) { | |
| this.items.push(element); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://juejin.cn/post/7325317637074960420 | |
| // WebSocket对象的创建 | |
| // WebSocket对象的关闭 | |
| // 启用心跳机制,避免断连 | |
| // 消息推送,接收到消息后进行业务逻辑处理 | |
| // 重连机制,如果断连后尝试一定次数的重连,超过最大次数后仍然失败则关闭连接 | |
| export default class WebSocketManager { |