Package crow.game.codec
Interface PacketHandler<T>
- Type Parameters:
T- The POJO that maps to the given packet.
- All Known Implementing Classes:
AccountInfoRequestHandler,AccountInfoResponseHandler,AccountListHandler,AccountReg2RequestHandler,AccountReg2ResponseHandler,AccountReg2StoreRequestHandler,AuthorizeUserHandler,AuthorizeUserResponseHandler,AuthRequestHandler,AuthResponseHandler,LoginFailedHandler,LoginRequestHandler,LoginSuccessHandler2016,LoginSuccessHandler20170315,LoginSuccessHandlerBase,PingHandler,PingPacketHandler,PongHandler,PongPacketHandler,SetAccountOfflineHandler,SetAccountOnlineHandler,SetAllAccountsOfflineHandler,UserCountHandler
public interface PacketHandler<T>
Interface responsible for converting to and from Packet objects to a POJO type
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfromPacket(Context ctx, PacketReader reader) Convert the given buffer to the type.voidWrites the object of type T to the byte buffer.static voidWrites the string to the given byte buffer, padding the given 0 bytes based on the length.
-
Method Details
-
fromPacket
Convert the given buffer to the type.- Parameters:
ctx- The calling context.reader- The input buffer stream reader.- Returns:
- The POJO object
- Throws:
Exception- on errors
-
toPacket
Writes the object of type T to the byte buffer.- Parameters:
ctx- The calling context.buffer- The destination buffer.src- The source object we are converting.- Throws:
Exception- on errors
-
rule
- Parameters:
ctx- The calling context.- Returns:
- The packet rule object which specifies when this packet handler should be called.
- See Also:
-
writeStr
Writes the string to the given byte buffer, padding the given 0 bytes based on the length.- Parameters:
buf- The buffer to write to.str- The string to write.len- The length of the string in the byte stream.
-