|
@@ -3,13 +3,14 @@ import flowMut from './flow/mutation-types'
|
|
|
import chatMut from './chat/mutation-types'
|
|
|
import flowService from '@/services/flowservice'
|
|
|
|
|
|
-let flow = {}, chat = {}
|
|
|
+let flow = {}
|
|
|
+let chat = {}
|
|
|
for (let k in flowMut) { flow[k] = 'flow/' + k }
|
|
|
for (let k in chatMut) { chat[k] = 'chat/' + k }
|
|
|
|
|
|
-export default store => {
|
|
|
- store.dispatch('chat/EVENT_ADD', {type: 'msg', handle: 'system', data: 'hello'})
|
|
|
+let targetws
|
|
|
|
|
|
+export default store => {
|
|
|
store.subscribe(mut => {
|
|
|
// console.log('I changed -- perform the connection somehow', mut)
|
|
|
if (mut.type === 'route/ROUTE_CHANGED') {
|
|
@@ -20,13 +21,20 @@ export default store => {
|
|
|
ctx,
|
|
|
'conn'
|
|
|
]
|
|
|
- let targetws = 'ws://' + urlPath.join('/')
|
|
|
+ targetws = 'ws://' + urlPath.join('/')
|
|
|
if (window.location.protocol === 'https:') {
|
|
|
targetws = 'wss://' + urlPath.join('/')
|
|
|
}
|
|
|
flowService.connect(targetws)
|
|
|
}
|
|
|
})
|
|
|
+ // DEBUG PURPOSES
|
|
|
+ window.dbgDisconnect = () => {
|
|
|
+ flowService.close()
|
|
|
+ }
|
|
|
+ window.dbgReconnect = () => {
|
|
|
+ flowService.connect(targetws)
|
|
|
+ }
|
|
|
|
|
|
// Connected
|
|
|
flowService.connected(() => {
|
|
@@ -40,7 +48,6 @@ export default store => {
|
|
|
})
|
|
|
|
|
|
flowService.on('document', (v) => {
|
|
|
- console.log('Store:', store)
|
|
|
store.commit(flow.DOCUMENT_UPDATE, v.data)
|
|
|
})
|
|
|
flowService.on('nodeUpdate', (v) => {
|
|
@@ -75,6 +82,7 @@ export default store => {
|
|
|
handle: store.state.chat.handle,
|
|
|
sessId: store.state.route.params.sessId
|
|
|
})
|
|
|
+ store.commit(chat.EVENTS_UPDATE, [])
|
|
|
})
|
|
|
|
|
|
/// // CHAT //////
|