Search in sources :

Example 1 with ArtemisMessage

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);
    }
}
Also used : ArtemisMessage(org.onosproject.artemis.impl.objects.ArtemisMessage) ByteBuf(io.netty.buffer.ByteBuf) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with ArtemisMessage

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);
}
Also used : ArtemisMessage(org.onosproject.artemis.impl.objects.ArtemisMessage) ByteBuf(io.netty.buffer.ByteBuf) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with ArtemisMessage

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);
}
Also used : ArtemisMessage(org.onosproject.artemis.impl.objects.ArtemisMessage) ByteBuf(io.netty.buffer.ByteBuf) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ByteBuf (io.netty.buffer.ByteBuf)3 ArtemisMessage (org.onosproject.artemis.impl.objects.ArtemisMessage)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1