Google-Code-Fork / tibiaapi

Automatically exported from code.google.com/p/tibiaapi
MIT License
0 stars 0 forks source link

Unify packet events #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Instead of having to cast the packets after our delegate is called, perhaps
it would be better to implement generics:

public delegate bool IncomingPacketDelegate<T>(T packet) where T :
IncomingPacket;
public delegate bool OutgoingPacketDelegate<T>(T packet) where T :
OutgoingPacket;

public event IncomingPacketDelegate<AnimatedTextPacket>
ReceivedAnimatedTextIncomingPacket;

Or, even better, if there were some way we could cut down on all the switch
statement code...

Original issue reported on code.google.com by ian320 on 3 Feb 2009 at 3:12

GoogleCodeExporter commented 9 years ago
Building on the original post, I think we need to unify the packet events. 
Currently
we have four different kinds:

In SocketBase:
public delegate bool IncomingPacketListener(Packets.IncomingPacket packet);
public delegate bool OutgoingPacketListener(Packets.OutgoingPacket packet);
public delegate void SplitPacket(byte type, byte[] packet);

In Proxy:
public delegate void MessageListener(NetworkMessage message);

These should all be converted to use Packets, and maybe merged into a single 
delegate
type.

Original comment by ian320 on 3 Feb 2009 at 3:31

GoogleCodeExporter commented 9 years ago
Fixed with r590.

Original comment by ian320 on 13 Mar 2009 at 7:00

GoogleCodeExporter commented 9 years ago

Original comment by ian320 on 13 Mar 2009 at 7:00