OSDN Git Service

Modified: Upload, Command execution
[eos/zephyr.git] / server / class / WebSocket.js
1 'use strict'
2
3 var fs = require('fs')
4 var socket;
5
6 var instance = {
7     connect: function(io) {
8         io.on('connection', function(s) {
9             socket = s;
10             console.log('connected');
11             socket.emit('connect', 'connected');
12         });
13     },
14     emit: function(event, data) {
15         socket.emit(event, data);
16     }
17         /*
18             array include obj
19             {
20                 data: blob,
21                 name: filename,
22                 dir : directory,
23             }
24         socket.on('upload', function(array) {
25             array.forEach(function(file) {
26                 var path = file.dir+'/'+file.name
27                 fs.writeFileSync(path, file.data)
28             })
29             socket.emit('done', 'success')
30         })
31         */
32 };
33
34 module.exports = { instance: instance };