How to use with MSDP? #3

Open
dannytatom opened this Issue Feb 6, 2017 · 2 comments

Projects

None yet

2 participants

@dannytatom

http://tintin.sourceforge.net/msdp/

This is what I'm doing:

const MSDP          = 69
const MSDP_VAR = 1
const MSDP_VAL = 2

let buffer = new Buffer(4)

buffer[0] = MSDP_VAR
buffer[1] = 'LIST'
buffer[2] = MSDP_VAL
buffer[3] = 'COMMANDS'

telnetOutput.writeSub(MSDP, buffer)

Nothing is returned. I'm pretty sure it's an issue on my end not sending it right, but not sure how to fix it?

@blinkdog
Owner
blinkdog commented Feb 7, 2017

I apologize in advance for covering some things you probably already know.

  • If you are writing a MUD server, you need to inform clients that you'll provide MSDP when requested:
    telnetOut.writeWill(MSDP);
  • If you are writing a MUD client, you need to negotiate before you subnegotiate, or the server might ignore your requests for MSDP:
    var isOkayToSubnegotiateWithServerAboutMSDP = false;
    telnetIn.on('will', function(option) {
        // Received: IAC WILL MSDP (69)
        if(option === MSDP) {
            // tell the server we want MSDP
            telnetOut.writeDo(MSDP);
            // set a flag to remind ourselves MSDP requests are OK now
            isOkayToSubnegotiateWithServerAboutMSDP = true;
        }
    });
  • When requesting MSDP, you'll need to form your subnegotiation buffer like so:
    // in some handler where we ask the server for MSDP
    if(isOkayToSubnegotiateWithServerAboutMSDP) {
        BUFFER_MSDP_VAR = Buffer.from([MSDP_VAR]);
        BUFFER_MSDP_VAL = Buffer.from([MSDP_VAL]);
        BUFFER_LIST = Buffer.from("LIST", "utf8");
        BUFFER_COMMANDS = Buffer.from("COMMANDS", "utf8");
        buffer = Buffer.concat([BUFFER_MSDP_VAR, BUFFER_LIST, BUFFER_MSDP_VAL, BUFFER_COMMANDS]);
        telnetOut.writeSub(MSDP, buffer);
    }
  • And then you'll need to listen for server responses:
    telnetIn.on('sub', function(option, buffer) {
        if(option === MSDP) {
            // Received: IAC SB MSDP <buffer> IAC SE
            // TODO: insert MSDP data parsing stuff here
            console.log(buffer); // we'll just display the buffer for now
        }
    });

Please let me know if this doesn't work for you.

@dannytatom

Actually my apologies for kinda half-assing the issue description.

I'm writing a client, and I have the initial will/do part going. My issue was how to send strings in the subnegotiation. The issue I was having was building a buffer that sent strings along (would instead send as ints?). Your solution worked, tho, so yay thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment