MtGox WebSocket连接不接受“订阅”消息,只“取消订阅”

时间:2013-12-14 23:41:17

标签: javascript websocket socket.io mtgox

以下是我正在使用的代码:

//Required functions
function onMessage(data) {
    //  console.log(data['channel']);
    console.log(data);
}

function onError(data) {
    console.log("Error:");
    console.log(data);
}

function onConnect(data) {
    console.log("Connected.");
    console.log(data);
}

function onDisconnect(data) {
    console.log("Disconnected.");
    console.log(data);
}   

function channelControl(action, channel) {
    var op = '';
    switch(action) {
        case 'subscribe':
            op = "subscribe";
        break;

        case "unsubscribe":
            op = "unsubscribe";
        break;

        default:
            return false;
        break;
    }
    var command = {
    "channel": channel,
    "op": op
    };
    conn.send(JSON.stringify(command));
    return true;
}

//Variables
var channel_ticker = 'd5f06780-30a8-4a48-a2f8-7ed181b4a13f';
var channel_trade = 'dbf1dee9-4f2e-4a08-8cb7-748919a71b21';
var channel_depth = '24e67e0d-1cad-4cc0-9e7a-f8523ef460fe';

//Main logic
console.log("Application Loaded");
var conn = io.connect('https://socketio.mtgox.com/mtgox');
conn.on('message',      onMessage);
conn.on('connect',    onConnect);
conn.on('disconnect', onDisconnect);
conn.on('error',      onError);

当我取消订阅频道时,它的效果非常好。但是,当我尝试订阅频道时,我收到错误:

Object {op: "remark", success: false, message: "Unknown command", debug: Object}

起初我只是假设我犯了一个简单的拼写错误,但在质疑我的理智和拼写单词订阅的时间太久之后,我感到很难过。有人有经验可以帮助我吗?非常感谢。

0 个答案:

没有答案