Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUDs ➜ General ➜ Suggested protocol for server to client "out of band" messages

Suggested protocol for server to client "out of band" messages

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18 19  20  21  22  23  

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #255 on Thu 25 Feb 2010 03:37 AM (UTC)
Message
Ha! It'll be a bit, I haven't had a chance to check out the code. I've been trying to get moving on my widget framework, for one thing, and for another we've got company coming over soon. But a decent mapper for Achaea is going to be awesome, and I can't wait to get my hands on it.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #256 on Fri 26 Feb 2010 05:23 AM (UTC)
Message

This is where I am heading with this stuff:

This shows a group in a fight, with all 3 sets of bars being updated in real time. Also you see how the target is faring.

On the top RH corner is the room name, exits, description, and contents.

On the bottom LH corner is the current map, showing where I am.

On the right is the "chat and combat log".

Although this is still a text MUD, you are more involved because you see what is happening around you, where you are, how your group is going, and what is in the room with you.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #257 on Fri 26 Feb 2010 11:26 PM (UTC)

Amended on Tue 26 Nov 2013 03:26 AM (UTC) by Nick Gammon

Message

I have made a YouTube video showing all this stuff in action, so you can see it is not just theory:

Demonstrated in the video are:

  • Mapper with zoom-in and zoom-out added
  • Box at the top which shows the room name, exits, description, npcs, players, and objects
  • Health bar windows for three players (grouped) - the leader is shown with a small crown symbol
  • Health bar window of mob currently being attacked
  • Experience bar
  • Chat and combat log (ie. normal text window) in a smaller size on the bottom-right

What the video makes clear is that it all works quickly and smoothly. It is fun and engaging to play.

The video has closed captioning in case you have trouble hearing (or can't understand my mumbling). Also YouTube can automatically translate the closed captions to other languages.

The video is HD - you can see more clearly if you choose a higher resolution in YouTube.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rash   United Kingdom  (56 posts)  Bio
Date Reply #258 on Sun 28 Feb 2010 02:26 AM (UTC)
Message
So your working this over in to C++ now Nick rather then C? Surely this would limit it's use for older Smaug muds (1.4/1.4a etc.) which still use C? For example I run a modified 1.4a base and wouldn't be able to move to SmaugFUSS due to the amount of work that's gone in to the base already. Do you have plan's to support the older bases?

Feel free to slap me about it I've completely mis-interrupted what's been said so far. It's late and I'm tired so brains not quite clicking full speed.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #259 on Sun 28 Feb 2010 03:19 AM (UTC)
Message
I used C++ because it gives you the standard template library, which gives you lists, vectors, strings, and all sorts of nice stuff.

You could use C if you didn't mind putting a lot of work into doing lists etc. a bit differently.

However converting Smaug to C++ isn't that bad. I think I did it in an afternoon a while back. I think you need to change "class" to "Class" (because "class" is a C++ keyword), and find a few other problems.

There is nothing stopping someone using another language (eg. Lua, Python, C) for the server end, but it just means you have to rewrite the changes I made to suit those languages. Then the plugins will still work.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #260 on Sun 28 Feb 2010 03:50 AM (UTC)

Amended on Sun 28 Feb 2010 03:55 AM (UTC) by Twisol

Message
For what it's worth, I'd like to throw my vote in with the JSON crowd, if it's not too late to change. I was looking at the 'group' example on page 12, and I realized that the format is really just a reinvented JSON. There are already a good many JSON libraries out there, for many languages. I'd also bet it's less overhead than maintaining a Lua environment simply for the purposes of parsing, and it doesn't bring with it the concerns about sending or calling functions from the data. It was mentioned that most formats have drawbacks, but since this one is semantically identical to JSON, there's no harm and a whole lot of good switching can do.

I took the time to convert the 'groups' example (page 12) to JSON. It's syntactically correct JSON (as per [1]), and you can see the clear similarities to the Lua-based format. The only semantic change I made is the ["group", {<parameters>}] root object, because it made more "abstract" sense to me than {"group": {<parameters>}}. It's a stylistic choice I suppose, but both could be effectively equal to Lua's group = {<parameters>}.

As a slightly humorous point also, you could maintain your Lua environment and include a Lua-based JSON library.

[
  "group",
  {
    "me": false,
    "combat": false,
    "leader": true,
    "debuffs": [],
    "name": "Jerirath",
    "position": "standing",
    "buffs": ["armor", "bless", "bless"],
    "level": 4,
    "xp": {
      "max": 42550,
      "cur": 3944
    },
    "stats": {
      "Mana": {
        "max": 91,
        "cur": 91
      },
      "HP": {
        "max": 73,
        "cur": 73
      },
      "Move": {
        "max": 230,
        "cur": 230
      }
    }
  },
  {
    "me": true,
    "combat": false,
    "follow": "Jerirath",
    "leader": false,
    "debuffs": [],
    "name": "Nick",
    "position": "standing",
    "buffs": ["bless", "bless", "armor"],
    "level": 4,
    "xp": {
      "max": 42550,
      "cur": 489
    },
    "stats": {
      "Mana": {
        "max": 94,
        "cur": 94
      },
      "HP": {
        "max": 72,
        "cur": 67
      },
      "Move": {
        "max": 230,
        "cur": 230
      }
    }
  }
]


See the JSON website [2] for more on JSON, as well as a comprehensive list of JSON implementations categorized by language. It's rather easier to grab one of those than somehow shoehorn Lua into, say, Visual Basic. And some languages, like Python, include JSON routines out of the box.

EDIT: fixed grammar and flow because I'm a grammar-and-flow fiend.


[1] jsonlint.com

[2] json.org

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #261 on Sun 28 Feb 2010 04:08 AM (UTC)

Amended on Sun 28 Feb 2010 04:11 AM (UTC) by Twisol

Message
Just for fun (and out of boredom) I threw together a side-by-side comparison of JSON and Lua in terms of a single entry of 'groups'. Wow, haha.

       JSON                  |           Lua
-----------------------------+----------------------------
[ "group",                   |  group = {
  {                          |    {
    "me": false,             |      me = false,
    "combat": false,         |      combat = false,
    "leader": true,          |      leader = true,
    "debuffs": [             |      debuffs = {
       ],                    |        },
    "name": "Jerirath",      |      name = "Jerirath"
    "position": "standing",  |      position = "standing",
    "buffs": [               |      buffs = {
      "armor",               |        "armor",
      "bless",               |        "bless",
      "bless"                |        "bless",
       ],                    |        },
    "level": 4,              |      level = 4,
    "xp": {                  |      xp = {
      "max": 42550,          |        max = 42550,
      "cur": 3944            |        cur = 3944,
      },                     |        },
    "stats": {               |      stats = {
      "Mana": {              |        Mana = {
        "max": 91,           |          max = 91,
        "cur": 91            |          cur = 91,
        },                   |          },
      "HP": {                |        HP = {
        "max": 73,           |          max = 73,
        "cur": 73            |          cur = 73,
        },                   |          },
      "Move": {              |        Move = {
        "max": 230,          |          max = 230,
        "cur": 230           |          cur = 230,
        }                    |          },
      }                      |        },
    }                        |      },
  } ]                        |    }

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #262 on Sun 28 Feb 2010 04:17 AM (UTC)
Message
Last post, I promise. It's worth noting that after decoding that JSON in Lua, I'm fairly sure (almost positive) that you'd access it the same way as the Lua version of the example. You would literally just use json.decode() instead of loadstring()().

Also, using the [] (array) syntax in JSON, as opposed to the {} (object) syntax, it's easier to access the message field. Using the former, you'd just use decoded_data[1] to get the message identifier, whereas with {} (and also the native Lua version, I imagine, though I can't check how you did yours) you'd have to inspect the object to discern the key first.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #263 on Sun 28 Feb 2010 04:33 AM (UTC)
Message
I admit I didn't use the Lua engine to decode client to server, so I am open to these suggestions.

Having said that, I don't want to bloat either the client or server with another large library, so I am hoping that the JSON code has no larger a footprint than Lua.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #264 on Sun 28 Feb 2010 04:37 AM (UTC)

Amended on Sun 28 Feb 2010 04:40 AM (UTC) by Twisol

Message
There's a SAX-like (event-based) JSON parser/validator library I'm looking at right now, I'm trying to see if I can add it to the Lua scripting interface in MUSHclient. Ideally I'd just push a new table on for each new object/array entered, and push key/value pairs into it as needed.

Also, I can tell you without even looking that JSON is far tinier than Lua. Most of the implementations I've seen so far consist of a single pair of .c/.h files. After all, Lua is a whole environment with syntax and function calls and a call stack. JSON is just a data format.

EDIT: Good news! YAJL (the SAX-like event-driven JSON parser) is hosted under Git, so we can take advantage of git's submodule functionality to maintain an external reference to the YAJL repository without bothering with the download-yourself-and-change-this stuff. A submodule is much like an SVN external, except it doesn't travel with the head of the repository but stays where you set it (which is generally a Good Thing).

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #265 on Sun 28 Feb 2010 05:25 AM (UTC)

Amended on Sun 28 Feb 2010 05:29 AM (UTC) by Twisol

Message
I'm looking into Jansson now instead, because it looks like YAJL will be too much hassle, not least because it doesn't provide for converting to JSON as well. Jansson also uses Git, as it happens.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #266 on Sun 28 Feb 2010 08:27 AM (UTC)
Message
Project update: Jansson turned out to be more or less for Unix only. I finally landed on json-c, which is working extremely well, and I like its API. I had to make a change to json_object.h, changing a typedef for 'boolean' to unsigned char instead of int, to fix an incompatibility with the Platform SDK. I'll be trying to write a Lua interface to it over the next couple days; preliminary experiments are promising.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #267 on Sun 28 Feb 2010 06:22 PM (UTC)
Message
IMO, the much harder problem isn't so much figuring out what format you send the data in, but rather what the semantic rules for the data chunks are in the first place. The main constraint to be placed on the data format is that it be expandable to some reasonable extent.

One advantage I see to using JSON is that it has a better defined format that doesn't allow the (IMO) wart-like behavior of non-primitive expressions that the current Lua thing does. (Then again, that protocol isn't really formally specified anywhere, so maybe this problem can be easily defined away once the protocol gets a specification. Again, the protocol is not just the data format but also, presumably, the meaning of the chunks.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Sproingie   USA  (8 posts)  Bio
Date Reply #268 on Sun 28 Feb 2010 06:51 PM (UTC)
Message
Count me in for JSON too. I'm not too pleased at how it requires the extra quoting noise for all key values, but I think the benefits outweigh it. Aside from not needing to parse some loosely-defined subset of lua literals, it's also easier to distinguish true arrays from key/value pairs, a distinction lua lacks (it's a mixed benefit in the Lua language, but it's a severe drawback as a wire protocol).

As for semantics, though it's nice to have as much shared semantics as possible, you're never going to get a universal interpretation, especially when different MUD codebases start using it. Most likely you'd want to stick some kind of "type" tag in each structured message so clients knew how to interpret it. MCP has a sophisticated version-aware capability negotiation system you might want to look at and adapt for this purpose.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #269 on Sun 28 Feb 2010 07:03 PM (UTC)
Message
Sproingie said:
it's also easier to distinguish true arrays from key/value pairs, a distinction lua lacks (it's a mixed benefit in the Lua language, but it's a severe drawback as a wire protocol).


Something I'm having trouble with when it comes to encoding a Lua table in JSON. In particular, how to convert an empty table in Lua? Will it be an array or an object? There's no way to tell. I'm opting for the "be explicit" approach, disallowing empty tables in favor of something like json.newarray() or json.newobject(). Well-formed Lua tables (with all-numeric or all-string keys) will automatically be encoded, of course.

Sproingie said:

As for semantics, though it's nice to have as much shared semantics as possible, you're never going to get a universal interpretation, especially when different MUD codebases start using it. Most likely you'd want to stick some kind of "type" tag in each structured message so clients knew how to interpret it. MCP has a sophisticated version-aware capability negotiation system you might want to look at and adapt for this purpose.


It's always possible to expand the root JSON array specification. The way I suggested before was [message, {parameters}], but to be version-aware I'm sure [message, {parameters}, version] would work just as well. Or even [[version, other protocol data], message, parameters], it depends on what you want really.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


928,612 views.

This is page 18, subject is 23 pages long:  [Previous page]  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18 19  20  21  22  23  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.