Page 2 of 3

Re: Open protocol support

Posted: Sun May 30, 2010 9:24 am
by Heiko
Mudlet does 2 things when a new atcp message arrives:
1. update the atcp message table where everything up to the first space is the message header and everything after the first space is the message content e. g. you send "myVar 50" or "myMessage foo bar" Mudlet will setup following entries in its atcp table: atcp.myVar = 50; atcp.myMessage = "foo bar"

2. After updating the atcp table Mudlet raises an event according to the atcp header with the atcp message content as parameter. This is the standard way to react to atcp events. Specify event handlers for your particular MUD events and handle them.

Re: Open protocol support

Posted: Tue Jun 01, 2010 12:20 pm
by KaVir
Thanks for the help. I've now implemented it as follows...

At any time after establishing a handshake, the client may send the following message:

Client: IAC SB ATCP "MSDP" IAC SE

This informs my mud that the ATCP option will be used to transmit MSDP data. The client can then indicate which variables it wishes the server to track, eg:

Client: IAC SB ATCP "REPORT HEALTH MANA" IAC SE

And the server will respond (adding "MSDP." to the front of each variable):

Server: IAC SB ATCP "MSDP.HEALTH 500" IAC SE
Server: IAC SB ATCP "MSDP.MANA 100" IAC SE

This data is sent immediately after the REPORT, and whenever a variable changes. Note the quotes indicate a string, but the quotes themselves are not transmitted.

So now I'd presumably need a plugin that would execute the following once at startup:

sendATCP "MSDP"
sendATCP "REPORT HEALTH MANA"

And the returned data would be automatically stored in the table as:

atcp.MSDPHEALTH = 500
atcp.MSDPMANA = 100

Then I'd just need to catch the events and update the gauges?

Re: Open protocol support

Posted: Tue Jun 01, 2010 12:48 pm
by Vadi
Hm, almost. Seems syntax for sendATCP is like so:

sendATCP(msg, content)

And implemented so:

Code: Select all

int TLuaInterpreter::sendATCP( lua_State *L )
{
    string msg;
    if( ! lua_isstring( L, 1 ) )
    {
        lua_pushstring( L, "wrong argument type" );
        lua_error( L );
        return 1;
    }
    else
    {
        msg = lua_tostring( L, 1 );
    }
    string what;
    if( ! lua_isstring( L, 2 ) )
    {
        lua_pushstring( L, "wrong argument type" );
        lua_error( L );
        return 1;
    }
    else
    {
        what = lua_tostring( L, 2 );
    }
    string _h;
    _h += TN_IAC;
    _h += TN_SB;
    _h += 200;
    _h += msg;
    _h += " ";
    _h += what;
    _h += TN_IAC;
    _h += TN_SE;

    Host * pHost = TLuaInterpreter::luaInterpreterMap[L];
    pHost->mTelnet.socketOutRaw( _h );
    return 0;
}

Because you specify a module + data to be sent: http://www.ironrealms.com/nexus/atcp.html

As such, sendATCP("MSDP", "") doesn't trigger because there is an extra space before or after in any way you do it. Perhaps chomp the strings on the server before processing them, that'd allow this scheme to work?

Re: Open protocol support

Posted: Tue Jun 01, 2010 1:08 pm
by KaVir
Vadi wrote:Because you specify a module + data to be sent: http://www.ironrealms.com/nexus/atcp.html

As such, sendATCP("MSDP", "") doesn't trigger because there is an extra space before or after in any way you do it. Perhaps chomp the strings on the server before processing them, that'd allow this scheme to work?
Easily done. Presumably "voted" and "keepalive" would have the same problem?

Re: Open protocol support

Posted: Tue Jun 01, 2010 1:20 pm
by Vadi
Seems so. It's never been used for IRE, just added for Avalon. I'll make a patch to have the second argument optional, and without it, it'll skip the space.

Re: Open protocol support

Posted: Tue Jun 01, 2010 1:55 pm
by Vadi
Please post when the change is in.

Re: Open protocol support

Posted: Tue Jun 01, 2010 9:05 pm
by KaVir
I just went over the code, and realised that it does already ignore a trailing space, because of the way it tokenises the data. So sending "MSDP " will work.

Re: Open protocol support

Posted: Wed Jun 02, 2010 11:12 pm
by KaVir
I had a bit more of a play with it, and sending:

sendATCP("MSDP", "")
sendATCP("REPORT", "HEALTH MANA ACTIONS")
display(atcp)


Displays:

table {
'MSDPMANA': '150'
'MSDPACTIONS': '1280'
'MSDPHEALTH': '1352'
}


So it seems to be working. My attempt at adding events broke the script entirely, but at least its working from the server side.

Re: Open protocol support

Posted: Thu Jun 03, 2010 1:41 am
by tsuujin
I didn't realize that ATCP is an interative element that IRE games accepted client input from other than the flags to activate.

Is there a list of what you can actually send with ATCP that will be responded to?

Re: Open protocol support

Posted: Thu Jun 03, 2010 2:25 am
by Vadi
On IRE games, nothing. Though with the upcoming expansion to ATCP, some commands seem to have been added but they aren't documented (decompiling the Nexus client will find you some).