如何在socket.io中创建云?与Ubuntu One一样,您将文件从计算机上传到服务器并保存。如何让服务器在socket.io中保存信息?
答案 0 :(得分:0)
:
SERVER
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
客户端
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost');
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
</script>
更多例子: