【发布时间】:2023-04-06 21:06:01
【问题描述】:
有人知道如何创建sockjs-node(SockJS - WebSocket 仿真)或Shoe 独立服务器吗?
没有http服务器可以crate吗?
只需要和dnode交换数据,不需要静态页面。
例如,当我在节点服务器端进行操作时:
var shoe = require('shoe');
var dnode = require('dnode');
var http = require('http');
var server = http
.createServer()
.listen(9999);
var echo = shoe
.createServer()
.on('connection', function(c)
{
var d = dnode(
{
test: function()
{
console.log('--------');
}
});
c
.on('data', function(message)
{
c.write(message);
})
.on('close', function() {});
c
.pipe(d)
.pipe(c);
c.on('close', function() {});
})
.installHandlers(server,
{
prefix: '/dnode'
});
以下代码(客户端)
var d = dnode()
.on('remote', function(remote)
{
remote.test();
});
d
.pipe(shoe('http://localhost/dnode'))
.pipe(d);
失败并出现以下错误:(Chrome)
GET http://localhost/dnode/info app.bundle.js:14681
AbstractXHRObject._start app.bundle.js:14681
(anonymous function)
【问题讨论】: