[DGD] Various questions
Raymond Jennings
shentino at gmail.com
Mon Jul 30 08:46:34 CEST 2018
On Fri, Jul 27, 2018 at 2:56 PM francisco del roio
<francipvb at hotmail.com> wrote:
>
> Hello,
>
> I’ve recently started to play with DGD and cloud server library and now that I got it running I have some questions regarding to my specific project needs.
>
>
> 1. How do you perform telnet negotiation and subnegotiation and where is the code under the mudlib?
If you're writing the code yourself, the code will naturally be
wherever you put it, but I would personally suggest keeping the code
working well with the code that handles the connections. If you're
using someone else's code, it depends on the mudlib in question but it
would probably be associated with connection handling as well. At the
least at some point the code handling the connection will need to
interface with the code handling the telnet protocol if they aren't
the same piece of code.
Internally, DGD's telnet ports have a simple implementation of this.
For telnet itself, I would suggest referencing RFC 854, which has the
official definition of the telnet protocol.
(https://tools.ietf.org/html/rfc854)
As for handling connections, there are three parts where you interface with DGD:
a. The kfun interface, which is what you use to close a connection,
block/unblock a connection, and send data.
Here, to close a telnet connection, the only way to close it from
DGD's side is to destruct the connection object, which is done with
the destruct_object kfun.
b. The driver object interface, which is a list of hooks that must be
implemented by the driver object.
See DGD's docs for more information, but basically, you need to return
an object to DGD for it to attach to inbound connections on the telnet
port (which turns the object into the aforementioned connection
object).
c. the connection object interface, which is a list of hooks that
need to be implemented by the connection object.
See DGD's docs as before, but in a nutshell this is the part where the
connection object handles events from the other side, like new input
arriving, or the other end disconnecting, or if the local output
buffer is ready to send more data.
But as for telnet itself, besides keeping it working with your
connection handling code, studying the RFC I mentioned is your best
resource.
> 2. What about translating text from and to various encodings within LPC? I want to send Spanish accents and not ascii symbols to clients.
Be forewarned, you are entering a compatibility minefield.
First of all, in LPC, strings are a concrete data type. A string is a
sequence of characters that are not necessarily null terminated.
Think of it as an array of char, a blob of binary data.
Each character is 8 bits.
That's as far as you can trust.
In LPC, if you index a string, you will get an int lvalue equal to the
8 bit character at that position in the string. Strings can be
concatenated with the + operator.
So as long as you know what to do, good old fashioned string indexing
and looping should be able to get done what you need.
If you want to work with spanish accents, for example, you should
decide how you're going to encode it.
Plain IBM does have native character codes (with the high bit set) for
accented vowels, and for the "pigtailed" c, and various math symbols.
Compatibility however is low.
If you don't want to transmit that, I would suggest using UTF-8. This
is my educated guess as to how to maximize compatibility. You should
be comfortable however in working with bitwise arithmetic because for
handling UTF8 you'll need to directly manipulate character values.
For accented characters, especially vowels, you can use the precoded
UTF8 character, or you can look into what are declared as "combining
characters" in unicode which are postfixes you can use to "tack on" an
accent to another character.
It probably goes without saying that you should probably try to make
sure the client you're sending the encodings to can handle the encoded
output. It's probably a good idea to make this user-configurable or
at least do some intelligent autodetection of the client.
When I said that messing with character encodings/accents was a
minefield I wasn't kidding.
> 3. How you do GMCP within LPC code? Is there a JSON encoder/decoder?
I don't know much about GMCP, but I would suggest researching it in
the same way as the telnet RFC.
As for JSON, you might try looking into parse_string for decoding and
incremental output/string concatenation for encoding.
> Note that I tried the kernellib before cloud server.
>
> Thanks so much.
>
> Cheers,
>
> Enviado desde Correo<https://go.microsoft.com/fwlink/?LinkId=550986> para Windows 10
>
> ____________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd
More information about the DGD
mailing list