package net.windwards.dnsfrontend.client;
import net.windwards.dnsfrontend.dialog.JSONProtocol;
import net.windwards.dnsfrontend.dialog.Message;
import net.windwards.dnsfrontend.dialog.ProtocolCodingException;
import net.windwards.dnsfrontend.dialog.Request;
import net.windwards.dnsfrontend.dialog.Update;
import java.io.IOException;
public class JSONClientProtocol extends JSONProtocol {
public byte[] encode(Update update) throws ProtocolCodingException {
try {
return this.mapper.writeValueAsBytes(update);
} catch (IOException e) {
throw new ProtocolCodingException(e);
}
}
public Message decode(byte[] data) throws ProtocolCodingException {
try {
return this.mapper.readValue(data, Message.class);
} catch (IOException e) {
throw new ProtocolCodingException(e);
}
}
}