wow-rp-addons / LibMSP

The “Mary Sue Protocol” (“MSP” for short) is a simple challenge/response protocol for RP UI add-ons within WoW to communicate with each other and publish text information to other clients (such as RP character names and descriptions).
Creative Commons Zero v1.0 Universal
2 stars 1 forks source link

Non-sending of empty fields #5

Closed ghost closed 6 years ago

ghost commented 6 years ago

This is regarding a portion of a CurseForge message sent some days ago.

One question: I noticed the library is sending the fields in the response even when the body is empty. This seems like a stupid waste of bandwidth. Would it break your add-ons if the fields without a value were no longer sent by LibMSP?

This would break things in unpleasant ways. Without sending the empty field, there's no way to distinguish between a field that has no content and a field that simply wasn't requested. Doing so would require to keep track of fields that were requested, and explicitly cycle through that record to make sure the field is actually empty.

However, what can be done is to reduce the sent data to a minimum. The bare minimum for an empty field can safely be reduced to 2-3 bytes, and XRP has done this for years safely, by skipping the version data entirely. If a client queries "?NF\001?RF" (Nonexistent Field/Real Field, for example's sake), responding with a simple "NF\001RF1=Content" is valid, cutting the reply for the empty field to 2 bytes (if no other fields are requested -- "?NF" -> "NF") or 3 bytes (adding the \001 separator).

I'll also demonstrate this in the modified development version I'll work on shortly.

Ellypse commented 6 years ago

Yeah, ultimately that question was really about micro-optimization. I believe the current version already only send the field, as two bytes, or something really close, so it might not be worth putting more effort into this ^^

Ellypse commented 6 years ago

I'm closing this issue, I agree it's better to keep the empty fields as an explicite indication that those fields are empty. It's not that much characters anyway :)