我正在尝试创建一个基于socket.io的服务器,但是每当我使用 dojo 由客户端连接到它时,它都会向我显示此错误:
debug - destroying non-socket.io upgrade
这是我的服务器代码
var express = require("express");
var io = require("socket.io");
server= express.createServer();
var server_socket = io.listen(server);
server_socket.sockets.on("connection",function(socket)
{
console.log("connection established");
socket.emit("message", message);
});
server.listen(8080);
这是我的客户代码
require(["dojox/socket"], function (socket)
{
var args, ws = typeof WebSocket != "undefined";
var _socket = dojox.socket(args = {
url: ws ? "ws://localhost:8080/" : "http://localhost:8080",
headers:{
"Content-Type":"application/x-www-urlencoded"
},
transport: function(args, message){
args.content = message; // use URL-encoding to send the message
// instead of a raw body
dojo.xhrPost(args);
}
});
websocket = dojox.socket.Reconnect(_socket);
websocket.on("message",function(data)
{
console.log(data);
});
});
请帮我。