class OFConnection implements IOFConnection, IOFConnectionBackend {

    @Override
    public void write(OFMessage m) {
        if (!isConnected()) {
            if (logger.isDebugEnabled())
                logger.debug("{}: not connected - dropping message {}", this, m);
            return;
        }
        if (logger.isDebugEnabled())
            logger.debug("{}: send {}", this, m);
        List<OFMessage> msgBuffer = localMsgBuffer.get();
        if (msgBuffer == null) {
            msgBuffer = new ArrayList<OFMessage>();
            localMsgBuffer.set(msgBuffer);
        }

        counters.updateWriteStats(m);
        msgBuffer.add(m);

        if ((msgBuffer.size() >= Controller.BATCH_MAX_SIZE) || ((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) {
            this.write(msgBuffer);
            localMsgBuffer.set(null);
        }
    }

    public  OFConnection(@Nonnull DatapathId dpid,
                        @Nonnull OFFactory factory,
                        @Nonnull Channel channel,
                        @Nonnull OFAuxId auxId,
                        @Nonnull IDebugCounterService debugCounters,
                        @Nonnull Timer timer);

}