2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.clients;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.channel.ChannelHandlerContext;
14 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 * Class representing sending message event
21 * @author michal.polkorab
23 public class SendEvent implements ClientEvent {
25 protected static final Logger LOGGER = LoggerFactory.getLogger(SendEvent.class);
26 protected byte[] msgToSend;
27 protected ChannelHandlerContext ctx;
30 * @param msgToSend message to be sent
32 public SendEvent(byte[] msgToSend) {
33 this.msgToSend = msgToSend;
37 public boolean eventExecuted() {
38 LOGGER.debug("sending message");
39 LOGGER.debug("start of run");
40 ByteBuf buffer = ctx.alloc().buffer();
41 buffer.writeBytes(msgToSend);
42 ctx.writeAndFlush(buffer);
43 LOGGER.debug(">> " + ByteBufUtils.bytesToHexString(msgToSend));
44 LOGGER.debug("message sent");
49 * @param ctx context which will be used for sending messages (SendEvents)
51 public void setCtx(ChannelHandlerContext ctx) {