Open protocol support

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Open protocol support

Post by Heiko » Sun May 30, 2010 9:24 am

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.

User avatar
KaVir
Posts: 86
Joined: Mon Feb 08, 2010 8:38 pm
Contact:

Re: Open protocol support

Post by KaVir » Tue Jun 01, 2010 12:20 pm

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?

User avatar
Vadi
Posts: 4728
Joined: Sat Mar 14, 2009 3:13 pm

Re: Open protocol support

Post by Vadi » Tue Jun 01, 2010 12:48 pm

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?

User avatar
KaVir
Posts: 86
Joined: Mon Feb 08, 2010 8:38 pm
Contact:

Re: Open protocol support

Post by KaVir » Tue Jun 01, 2010 1:08 pm

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?

User avatar
Vadi
Posts: 4728
Joined: Sat Mar 14, 2009 3:13 pm

Re: Open protocol support

Post by Vadi » Tue Jun 01, 2010 1:20 pm

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.

User avatar
Vadi
Posts: 4728
Joined: Sat Mar 14, 2009 3:13 pm

Re: Open protocol support

Post by Vadi » Tue Jun 01, 2010 1:55 pm

Please post when the change is in.

User avatar
KaVir
Posts: 86
Joined: Mon Feb 08, 2010 8:38 pm
Contact:

Re: Open protocol support

Post by KaVir » Tue Jun 01, 2010 9:05 pm

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.

User avatar
KaVir
Posts: 86
Joined: Mon Feb 08, 2010 8:38 pm
Contact:

Re: Open protocol support

Post by KaVir » Wed Jun 02, 2010 11:12 pm

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.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Open protocol support

Post by tsuujin » Thu Jun 03, 2010 1:41 am

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?

User avatar
Vadi
Posts: 4728
Joined: Sat Mar 14, 2009 3:13 pm

Re: Open protocol support

Post by Vadi » Thu Jun 03, 2010 2:25 am

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).

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests