summaryrefslogtreecommitdiff
path: root/app/client/socket
diff options
context:
space:
mode:
Diffstat (limited to 'app/client/socket')
-rw-r--r--app/client/socket/index.js2
-rw-r--r--app/client/socket/socket.api.js32
2 files changed, 34 insertions, 0 deletions
diff --git a/app/client/socket/index.js b/app/client/socket/index.js
index a5d9987..3caab6d 100644
--- a/app/client/socket/index.js
+++ b/app/client/socket/index.js
@@ -6,6 +6,7 @@ import * as actions from './socket.actions'
import * as system from './socket.system'
import * as live from './socket.live'
import * as task from './socket.task'
+import * as api from './socket.api'
export default {
socket,
@@ -13,6 +14,7 @@ export default {
system,
live,
task,
+ api,
}
socket.on('status', (data) => {
diff --git a/app/client/socket/socket.api.js b/app/client/socket/socket.api.js
new file mode 100644
index 0000000..99c9248
--- /dev/null
+++ b/app/client/socket/socket.api.js
@@ -0,0 +1,32 @@
+import { dispatch } from '../store'
+import types from '../types'
+import { socket } from './socket.connection'
+
+socket.on('api_res', (data) => {
+ // console.log('system response', data)
+ const type = types[data.datatype]
+ if (! type) return console.error('socket:api_res bad datatype', data.datatype)
+ switch (data.type) {
+ case 'create':
+ return dispatch({
+ type: type.create,
+ source: 'socket',
+ data: data.data,
+ })
+ case 'update':
+ return dispatch({
+ type: type.update,
+ source: 'socket',
+ data: data.data,
+ })
+ case 'destroy':
+ return dispatch({
+ type: type.destroy,
+ source: 'socket',
+ data: data.data,
+ })
+ default:
+ break
+ }
+})
+