小编Que*_*eUe的帖子

Android socket.io 应用程序无法连接到 node.js 服务器

我的应用程序使用 socket.io,无法连接到 node.js 服务器。

服务器节点.js

var app = require('http').createServer()
var io = require('socket.io')(app);

app.listen(1000);

io.on('connection', function (client) { 

  client.name = client.remoteAddress + ':' + client.remotePort;
  console.log(client.name + ' connected!'); 

    client.on('sensorChanged', function (data) {
        console.log("HERE");
        console.log(data);
    });

});
Run Code Online (Sandbox Code Playgroud)

安卓应用:

    SocketIO socket = new SocketIO();
    try {
        socket.connect("http://localhost:1000/", this);
        txtView.setText("connected");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    socket.emit("sensorChanged", "argument1");
Run Code Online (Sandbox Code Playgroud)

当我连接到服务器时,服务器不会说“socket.name connected”,也不会发出事件“sensorChanged”。问题出在哪儿?

android node.js socket.io

5
推荐指数
2
解决办法
5865
查看次数

在静态方法中读取 cookie

我在静态方法中读取 cookie 时遇到问题。我试过:

static void Method()
{
    Page page = HttpContext.Current.Handler as Page;
         HttpCookie reader= page.Request.Cookies["myCookie"];
}
Run Code Online (Sandbox Code Playgroud)

但我认为这不起作用。

你有什么想法我该怎么做吗?

.net c# cookies static static-methods

3
推荐指数
1
解决办法
4044
查看次数

标签 统计

.net ×1

android ×1

c# ×1

cookies ×1

node.js ×1

socket.io ×1

static ×1

static-methods ×1