Quote:
Everybody is welcome to suggest it own ideas, and implementations!
Ok, on behalf of this here are my implementation thoughts, visions and idea's...
XKore serverTypesI think that serverTypes for XKore are not needed,
we can use the unpack strings from the receive part and use them to pack data into a packet that we send to the client.
However, we need perfect unpacking in order to be able to do perfect packing. (look at it this way, its easier to unpack a suitcase than to pack it)
XKore/Posseidon serverI know nothing about posseidon but it looks like xkore 2 to me in a way.
Couldn't we merge the 2 and make posseidon a special case of xkore 2?
In xkore2 we could add more features like read only. (kore will send to the RO client but will only do something with the keepalive packet)
Complex Packetsi suggest we use the
Convert::Binary::C package until perl adds native support to do what we want.
We will need to change the structure of the packet_list attribute to support normal unpacking or complex (un)packing:
OLD:
Code:
'packetSwitch' => ['handler function','unpack string',[qw(argument names)]]
NEW:
0) normal (un)packing
Code:
'packetSwitch' => ['handler function', 0,'unpack string',[qw(argument names)]]
1) complex (un)packing
Code:
'packetSwitch' => ['handler function', 1,'struct name', [tag options...]]
these tags options will help us to do special unpacking like:
Code:
$c->tag('test1.auction[0].seller', Format => 'String');
$c->tag('test1.auction[0].buyer', Format => 'String');
An alternative vs Convert::Binary::C could be this:
1) complex (un)packing
Code:
'packetSwitch' => ['handler function', 1,'complex perl unpack function', 'complex perl pack function']]
This 'complex perl (un)pack function' will do the same thing as the Convert::Binary::C:
for unpacking it will return an unpacked perl hash structure to the 'handler function' (or straight to $environment_change_Queue)
for packing it will take a perl hash structure as an argument and pack this accordingly, so we can send it.
Send PartWe can re-factor the send part so that it looks more like its receive counterpart.
To do this we will have to separate the pack-strings (that we now use in the subs) into some kind of object that holds a table of all pack-strings.
Maybe it is possible to merge all pack and unpack into 1 single table.
(reference: look at Receive/Sakexe_0.pm, it seems like there is no packet-switch (packet ID) being used on both send and receive part, or am i wrong about this?)
Otherbtw, is stringToBytes etc. really needed when we use the perl pack function instead of just appending a string to a string? It would be nice if they were obsolete.
Look at this example please. By only using the pack function we don't only make the code shorter, it also adds the possibility to do what is explained in the paragraph: Send Part.
old:
Code:
sub sendChatRoomBestow {
my ($self, $name) = @_;
my $binName = stringToBytes($name);
$binName = substr($binName, 0, 24) if (length($binName) > 24);
$binName .= chr(0) x (24 - length($binName));
my $msg = pack("C*", 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00) . $binName;
$self->sendToServer($msg);
debug "Sent Chat Room Bestow: $name\n", "sendPacket", 2;
}
new:
Code:
sub sendChatRoomBestow {
my ($self, $name) = @_;
my $msg = pack('v x4 Z24', 0x00E0, stringToBytes($name));
$self->sendToServer($msg);
debug "Sent Chat Room Bestow: $name\n", "sendPacket", 2;
}
Can someone that uses such foreign languages test this?