StompJs仅在调试模式下工作-React Native

时间:2019-08-16 04:44:05

标签: react-native websocket stompjs

import * as Stomp from "stompjs";
import _ from "lodash";
export const MESSAGE_TYPE_CHAT_TYPING = "ChatTyping";
export const MESSAGE_TYPE_CHAT_MESSAGE = "ChatMessage";
export const RECONNECT_DELAY = 3000;

export function wsConnect(user, callback, ondisconnected) {

 const webSocket = Stomp.client(url);
 webSocket.debug = () => {};
 webSocket.connect({},() => {
   callback ? callback(webSocket) : _.noop();
  },
  error => {
    // console.log(error);
    console.log("Connection lost...");
    if (ondisconnected) {
      ondisconnected();
     }
   }
  );

  return webSocket;
 }

仅当应用程序处于调试模式时,才通过WebSocket建立StompJ之间的连接。

0 个答案:

没有答案