summaryrefslogtreecommitdiff
path: root/frontend/src/utils/createWebSocketConnection.js
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2017-01-20 16:11:24 +0100
committerjbion <joffrey.bion@amadeus.com>2017-01-20 16:11:35 +0100
commitb32cdf5c4f5d0b4f31b3bcfa64fe9328ed78d818 (patch)
treebdda009d448cb6b56415d90eae90eceb138318e4 /frontend/src/utils/createWebSocketConnection.js
parentMerge remote-tracking branch 'origin/feature/front' (diff)
downloadseven-wonders-b32cdf5c4f5d0b4f31b3bcfa64fe9328ed78d818.tar.gz
seven-wonders-b32cdf5c4f5d0b4f31b3bcfa64fe9328ed78d818.tar.bz2
seven-wonders-b32cdf5c4f5d0b4f31b3bcfa64fe9328ed78d818.zip
Move frontend and backend into 2 separate subprojects
Diffstat (limited to 'frontend/src/utils/createWebSocketConnection.js')
-rw-r--r--frontend/src/utils/createWebSocketConnection.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/frontend/src/utils/createWebSocketConnection.js b/frontend/src/utils/createWebSocketConnection.js
new file mode 100644
index 00000000..b0924976
--- /dev/null
+++ b/frontend/src/utils/createWebSocketConnection.js
@@ -0,0 +1,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