Closed 521guyu closed 4 years ago
@ @lahsivjar
您有没有使用的实例,从建立连接到断开连接所有方法都包括的,<SockJsClient //onDisconnect={this.connect.bind(this)} //连接丢失后的回调 url={apiUrl.warn} topics={["/warn"]} onMessage={this.onMessage.bind(this)} onConnect={this.onConnect.bind(this)} onConnectFailure={this.onConnectFailure.bind(this)} debug={true} autoReconnect={true} //断开连接是否自动连接 ref={client => { this.clientRef = client; }} />
连接和断开连接怎么写呢???
If I understand correctly you want to call disconnect
explicitly. If that is the case you can use the disconnect
API: https://github.com/lahsivjar/react-stomp/blob/master/API.md#disconnect
For usage see this: https://github.com/lahsivjar/react-stomp/blob/master/test/e2e/connect.test.js#L22-L40
``connect = () => { this.clientRef.connect(SockJsClient)//调用这个需要传的参数 console.log('建立连接',this.clientRef.connect(SockJsClient),this) }
我现在不知到需要传什么参数,api都是源码感觉,看不太懂
我按照你这个写的,我写了一个按钮断开连接,可以,又写了一个建立连接不行,报iframe.js?1a47:77 Uncaught TypeError: Cannot read property 'contentWindow' of null at eval (iframe.js?1a47:77),现在就是不知道要传什么参数
和使用方法
disconnect = (a) => {//断开连接 console.log("断开连接", this.clientRef.disconnect()) }
这个是断开连接的
希望有一个react中使用的实例和更容易的api文档
请问如何断开连接,有没有使用实例或者api文档