Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init(attempt) {
attempt = attempt || 1;
clearTimeout(this.timeout);
this.socket = new SockJS('/_sock');
this.socket.onopen = async () => {
if (!this.isFirstTime) {
await fetchSessionToken();
this.eventEmitter.emit('SOCKET_RECONNECT');
}
this.isFirstTime = false;
// Buffering request while Socket is still starting up
this.buffer.forEach((req) => {
this._doSend(req);
});
this.buffer = [];
};
this.socket.onmessage = (event) => {
created () {
this.portfolioId = Number(this.$route.params.id)
const socket = new SockJS('/stomp')
this.client = Stomp.over(socket)
this.client.debug = null
let self = this
this.client.connect({}, frame => {
console.log('Connected: ' + frame)
self.client.subscribe('/topic/solution', message => {
const data = JSON.parse(message.body)
// console.log(data.status)
if (data.id === this.portfolioId) {
self.status = data.status
self.portfolio = data.portfolio
}
})
})
axios.get(`/api/portfolio/${this.portfolioId}`).then(res => {
initializeWebSocketConnection(){
let ws = new SockJS(this.serverUrl);
this.stompClient = Stomp.over(ws);
let that = this;
this.stompClient.connect({}, function(frame) {
that.stompClient.subscribe("/chat", (message) => {
if(message.body) {
$(".chat").append("<div class="message">"+message.body+"</div>")
console.log(message.body);
}
});
});
}
_connect(draw) {
const { selectedSf, selectedAp, dataset } = this.props;
var apCode = selectedAp.apCode;
var stamp = selectedSf.toJS().stamp;
socket = new SockJS(
DOMAIN + 'sensing_data'
);
socket.onclose = () => {
stompClient.disconnect();
console.log('disconnected')
};
stompClient = Stomp.over(socket);
stompClient.connect('manager', 'manager', function (frame) {
console.log('Connected: ' + frame);
stompClient.subscribe('/topic/messages' + apCode + stamp, draw);
});
}
export function* connectWS() {
yield take(REQUEST_CONFIG_SUCCESS);
const user = yield select(userConfigSelector);
const messagesURLs = yield select(localizationSelector);
if (!isEmpty(user) && user.token && !isEmpty(messagesURLs)) {
const socket = yield new SockJS(
getServerURL(messagesURLs.wsUrl) + user.token
);
return Stomp.over(socket);
}
throw new Error("Not access token or not message url");
}
initSocket() {
const socket = new SockJS(`${WEBSOCKET_SERVER}/websocket`);
socket.onmessage = (e) => {
if (e.data && e.data.action === 'SYS_REPEAT_LOGIN') {
socket.close();
repeatLogin();
}
};
}
function createSocket(url, backendOptions, callback) {
callback(new SockJS(url, null, backendOptions));
}
constructor({
port = 6001,
protocol = window.location.protocol,
hostname = window.location.hostname
}) {
this.connection = new SockjsClient(
urlFormat({
protocol,
hostname,
port,
pathname: '/sockjs-node'
})
);
this.connection.onclose = this.handleClose;
this.connection.onmessage = this.handleMessage;
this.handleConnected();
}
function onStart() {
socket = new SockJS(endpoint)
socket.onopen = onOpen
socket.onclose = onStop
socket.onmessage = onMessage
}