Created
July 30, 2013 20:07
-
-
Save volgar1x/6116424 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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