Unity3d websocket+;simplejson解析不';行不通

Unity3d websocket+;simplejson解析不';行不通,json,unity3d,websocket,Json,Unity3d,Websocket,我有个问题,我的while(loop)实际上不起作用。这是Unity3D免费websocket资产中的一个修改示例。我可以将json发送到node.js服务器,但无法接收json。显然,循环或字符串的接收肯定有问题。因为我的Debug.Log只播放一次(只播放第一个“while”)。如果我执行If reply==null,那么我将再次收到一个日志。所以似乎没有数据到达。。。但是我的循环不应该一次又一次地工作吗 也许你能帮我摆脱困境。非常感谢!:) 带上node js服务器代码可能会有所帮助: /

我有个问题,我的while(loop)实际上不起作用。这是Unity3D免费websocket资产中的一个修改示例。我可以将json发送到node.js服务器,但无法接收json。显然,循环或字符串的接收肯定有问题。因为我的Debug.Log只播放一次(只播放第一个“while”)。如果我执行If reply==null,那么我将再次收到一个日志。所以似乎没有数据到达。。。但是我的循环不应该一次又一次地工作吗

也许你能帮我摆脱困境。非常感谢!:)

带上node js服务器代码可能会有所帮助:

// Websocket-Server
var WebSocketServer = require('ws').Server
var wss = new WebSocketServer({host: 'localhost',port: 8000});


wss.on('connection', function(ws) 
{
    var clients = {};

    console.log('client verbunden...');


    ws.on('message', function (data) {
    console.log('von Client empfangen: '+data );
    var obj = JSON.parse(data);

          if("id" in obj) {
            // New client, add it to the id/client object
            clients[obj.id] = obj.id;
            console.log('client: ' + obj.id);
          } 
          else {
            // Send data to the client requested
            clients[obj.to].send(obj.data);
            console.log('send: ' + obj.data);
          }
    })
     /* ws.on('message', function(message) 
    {
        console.log('von Client empfangen: ' + message);
        ws.send('von Server empfangen: ' + message);
    });*/

});

try
返回空值而不是
返回0和问题:你有错误打印吗?你也可以在Unity3D控制台中选择折叠相同的打印。哦,我太傻了。是的,它倒塌了!返回null和返回零是相同的结果。但是我如何捕捉Json呢?没有错误,只需Debug.Log(“while”)。
// Websocket-Server
var WebSocketServer = require('ws').Server
var wss = new WebSocketServer({host: 'localhost',port: 8000});


wss.on('connection', function(ws) 
{
    var clients = {};

    console.log('client verbunden...');


    ws.on('message', function (data) {
    console.log('von Client empfangen: '+data );
    var obj = JSON.parse(data);

          if("id" in obj) {
            // New client, add it to the id/client object
            clients[obj.id] = obj.id;
            console.log('client: ' + obj.id);
          } 
          else {
            // Send data to the client requested
            clients[obj.to].send(obj.data);
            console.log('send: ' + obj.data);
          }
    })
     /* ws.on('message', function(message) 
    {
        console.log('von Client empfangen: ' + message);
        ws.send('von Server empfangen: ' + message);
    });*/

});