use of org.onosproject.artemis.impl.objects.ArtemisMessage in project onos by opennetworkinglab.
the class MoasClientHandler method channelActive.
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
log.info("Connected to server {}", ctx.channel().remoteAddress());
ArtemisMessage message = new ArtemisMessage();
message.setType(ArtemisMessage.Type.INITIATE_FROM_CLIENT);
message.setLocalIp(localIp.toString());
message.setLocalPrefix(localPrefix.toString());
ObjectMapper mapper = new ObjectMapper();
try {
String jsonInString = mapper.writeValueAsString(message);
ByteBuf buffer = Unpooled.copiedBuffer(jsonInString, CharsetUtil.UTF_8);
ctx.writeAndFlush(buffer);
} catch (JsonProcessingException e) {
log.warn("channelActive()", e);
}
}
use of org.onosproject.artemis.impl.objects.ArtemisMessage in project onos by opennetworkinglab.
the class MoasServerHandler method channelRead.
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws IOException {
ByteBuf in = (ByteBuf) msg;
String strMsg = in.toString(io.netty.util.CharsetUtil.US_ASCII);
ObjectMapper mapper = new ObjectMapper();
ArtemisMessage actObj = mapper.readValue(strMsg, ArtemisMessage.class);
controller.packetAgent.processMoasPacket(actObj, ctx);
}
use of org.onosproject.artemis.impl.objects.ArtemisMessage in project onos by opennetworkinglab.
the class MoasClientHandler method channelRead.
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws IOException {
ByteBuf in = (ByteBuf) msg;
String strMsg = in.toString(io.netty.util.CharsetUtil.US_ASCII);
ObjectMapper mapper = new ObjectMapper();
ArtemisMessage actObj = mapper.readValue(strMsg, ArtemisMessage.class);
packetProcessor.processMoasPacket(actObj, ctx);
}
Aggregations