// Path: src/main/java/org/tools4j/hoverraft/direct/DirectPayload.java
// public interface DirectPayload {
// 
//     int byteLength();
// 
//     int offset();
// 
//     DirectBuffer readBufferOrNull();
// 
//     MutableDirectBuffer writeBufferOrNull();
// 
//     void wrap(DirectBuffer buffer, int offset);
// 
//     void wrap(MutableDirectBuffer buffer, int offset);
// 
//     void unwrap();
// 
//     default boolean isWrapped() {
//         return readBufferOrNull() != null || writeBufferOrNull() != null;
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/event/Event.java
// public interface Event {
//     Transition accept(ServerContext serverContext, EventHandler eventHandler);
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/transport/ResendStrategy.java
// public interface ResendStrategy {
//     <M extends Message> void onRejectedOffer(Sender<? super M> sender, M message, long rejectReason);
// 
//     ResendStrategy NOOP = new ResendStrategy() {
//         @Override
//         public <M extends Message> void onRejectedOffer(Sender<? super M> sender, M message, long rejectReason) {
//             //no op
//         }
//     };
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/transport/Sender.java
// public interface Sender<M extends DirectPayload> {
//     /**
//      * Terminates composing and offsers the message to the transport in
//      * non-blocking mode. Can be called multiple times for same message if sending
//      * failed which is indicated through a negative return value.
//      *
//      * @param message the message to send
//      * @return Non-negative transpport state such as position, otherwise zero if
//      * not applicable and successful or a negative error value
//      * {@link RejectReason#NOT_CONNECTED}, {@link RejectReason#BACK_PRESSURED},
//      * {@link RejectReason#ADMIN_ACTION} or {@link RejectReason#CLOSED}.
//      */
//     long offer(M message);
// }


import org.tools4j.hoverraft.direct.DirectPayload;
import org.tools4j.hoverraft.event.Event;
import org.tools4j.hoverraft.transport.ResendStrategy;
import org.tools4j.hoverraft.transport.Sender;
/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2016-2017 hover-raft (tools4j), Marco Terzer
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.tools4j.hoverraft.message;


/**
 * Base interface for all messages.
 */
public interface Message extends DirectPayload, Event {

    MessageType type();

// Path: src/main/java/org/tools4j/hoverraft/direct/DirectPayload.java
// public interface DirectPayload {
// 
//     int byteLength();
// 
//     int offset();
// 
//     DirectBuffer readBufferOrNull();
// 
//     MutableDirectBuffer writeBufferOrNull();
// 
//     void wrap(DirectBuffer buffer, int offset);
// 
//     void wrap(MutableDirectBuffer buffer, int offset);
// 
//     void unwrap();
// 
//     default boolean isWrapped() {
//         return readBufferOrNull() != null || writeBufferOrNull() != null;
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/event/Event.java
// public interface Event {
//     Transition accept(ServerContext serverContext, EventHandler eventHandler);
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/transport/ResendStrategy.java
// public interface ResendStrategy {
//     <M extends Message> void onRejectedOffer(Sender<? super M> sender, M message, long rejectReason);
// 
//     ResendStrategy NOOP = new ResendStrategy() {
//         @Override
//         public <M extends Message> void onRejectedOffer(Sender<? super M> sender, M message, long rejectReason) {
//             //no op
//         }
//     };
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/transport/Sender.java
// public interface Sender<M extends DirectPayload> {
//     /**
//      * Terminates composing and offsers the message to the transport in
//      * non-blocking mode. Can be called multiple times for same message if sending
//      * failed which is indicated through a negative return value.
//      *
//      * @param message the message to send
//      * @return Non-negative transpport state such as position, otherwise zero if
//      * not applicable and successful or a negative error value
//      * {@link RejectReason#NOT_CONNECTED}, {@link RejectReason#BACK_PRESSURED},
//      * {@link RejectReason#ADMIN_ACTION} or {@link RejectReason#CLOSED}.
//      */
//     long offer(M message);
// }


// Path: src/main/java/org/tools4j/hoverraft/message/Message.java
import org.tools4j.hoverraft.direct.DirectPayload;
import org.tools4j.hoverraft.event.Event;
import org.tools4j.hoverraft.transport.ResendStrategy;
import org.tools4j.hoverraft.transport.Sender;

/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2016-2017 hover-raft (tools4j), Marco Terzer
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.tools4j.hoverraft.message;


/**
 * Base interface for all messages.
 */
public interface Message extends DirectPayload, Event {

    MessageType type();

    default void sendTo(final Sender<? super Message> sender, final ResendStrategy resendStrategy) {