RejectedSoftware Forums

Sign up

Having trouble getting started with attachments/metadata

Hi,

I'm in the process of creating a proof of concept Minecraft server using D and Vibe.D.

I need to be able to associate one piece of metadata to each TCPConnection being used (in this case, PacketType - An enumeration containing STATUS, LOGIN, HANDSHAKE, and GAME).

Is there any way to do this in Vibe.D itself? I couldn't find how to do it.

I also tried using an associative array of PacketTypes, using TCPConnection as the key. That didn't work - It always returned that the first entry was the incoming connection, even when it wasn't.

Sorry if this is a dumb question, but it has me stumped.

~Cruz

Re: Having trouble getting started with attachments/metadata

Never mind :)

I just discovered getTaskLocal and setTaskLocal.

Re: Having trouble getting started with attachments/metadata

On Fri, 24 Jan 2014 13:27:15 GMT, Cruz Bishop wrote:

Never mind :)

I just discovered getTaskLocal and setTaskLocal.

If this works for your use case, have a look at TaskLocal!T. It's the more efficient and type safe successor of those two functions.

I would have expected the associative array to work, too, but maybe the hash function behaves strangely for interfaces. You could try to use a T[void*] instead of T[TCPConnection] and explicitly cast the connection to void* when accessing the AA.