Skip to content

Instantly share code, notes, and snippets.

@volgar1x
Created July 30, 2013 20:07
Show Gist options
  • Save volgar1x/6116424 to your computer and use it in GitHub Desktop.
Save volgar1x/6116424 to your computer and use it in GitHub Desktop.
class DofusDecoder extends MessageToMessageDecoder[ByteBuf] {
def decode(ctx: ChannelHandlerContext, msg: ByteBuf, out: util.List[AnyRef]) {
}
}
class DofusEncoder extends MessageToMessageEncoder[Message] {
def encode(ctx: ChannelHandlerContext, msg: Message, out: util.List[AnyRef]) {
val serializer = implicitly[Serializer[msg.type, String]]
out.add(serializer(msg))
}
}
trait Message {
val header: String
}
trait Serializer[T, To] {
def serialize(msg: T): To
def apply(msg: T): To = serialize(msg)
}
trait Deserializer[T, From] {
def deserialize(input: From): T
def apply(input: From): T = deserialize(input)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment