我有一个非常简单的节点服务器,它监听一个套接字并将消息传输到所有客户端(flex)。虽然这适用于发布消息的客户端,但我也希望能够通过 Web API 发布消息。可能吗?
var express = require('express');
var app = express();
var io = require('socket.io').listen(server, {
flashPolicyServer: true,
transports: ['flashsocket', 'websocket', 'htmlfile', 'xhr-polling', 'jsonp-polling']});
io.sockets.on('connection', function(client) {
client.on('invalidation', function(message) {
client.emit('message', message); // send message to sender
client.broadcast.emit('message', message); // send message to everyone else but the sender
});
client.on('disconnect', function(client) {});
});