summaryrefslogtreecommitdiff
path: root/frontend/src/utils/createWebSocketConnection.js
blob: b0924976b2c77d58100d20ef8db2b05e11a15f58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import SockJS from 'sockjs-client'
import Stomp from 'webstomp-client'
const wsURL = 'http://localhost:8080/seven-wonders-websocket'

const createConnection = (headers = {}) => new Promise((resolve, reject) => {
    let socket = Stomp.over(new SockJS(wsURL), {
      debug: process.env.NODE_ENV !== "production"
    })
    socket.connect(headers, (frame) => {
      return resolve({ frame, socket })
    }, reject)
})

export default createConnection
bgstack15