简体   繁体   中英

Is it possible to unsubscribe from a MtGox API channel using socket.io?

The following code does not seem to do anything. Is there a way of unsubscribing?

var MTGOX  = 'https://socketio.mtgox.com/mtgox';
var conn = io.connect(MTGOX);
conn.emit({ 
  'channel':'d5f06780-30a8-4a48-a2f8-7ed181b4a13f',
  'op':'mtgox.unsubscribe'
});

The Mt.Gox API responds to "message" events, so you should be using Socket.IO's send command.

conn.send({
    "channel": "d5f06780-30a8-4a48-a2f8-7ed181b4a13f",
    "op": "unsubscribe"
});

To unsubscribe from a channel, send the op "unsubscribe". To subscribe , send the op "mtgox.subscribe" (as listed on the bitcoin.it wiki) .

This is the alternative method (for clarification):

conn.emit('message', {
    "channel": "d5f06780-30a8-4a48-a2f8-7ed181b4a13f",
    "op": "unsubscribe"
});

The example here: https://en.bitcoin.it/wiki/MtGox/API/Streaming#op:subscribe_and_op:unsubscribe shows the op name as just "unsubscribe" whereas you have "mtgox.unsubscribe". Can you try without the prefix, and/or let us know where you got that prefix from?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM