// Path: src/main/java/com/goodow/realtime/channel/Bus.java
// @JsType
// public interface Bus {
//   String ON_OPEN = "@realtime/bus/onOpen";
//   String ON_CLOSE = "@realtime/bus/onClose";
//   String ON_ERROR = "@realtime/bus/onError";
// 
//   /**
//    * Close the Bus and release all resources.
//    */
//   void close();
// 
//   /* The state of the Bus. */
//   State getReadyState();
// 
//   /* Returns the session ID used by this bus. */
//   String getSessionId();
// 
//   /**
//    * Publish a message
//    *
//    * @param topic The topic to publish it to
//    * @param msg The message
//    */
//   Bus publish(String topic, Object msg);
// 
//   /**
//    * Publish a local message
//    *
//    * @param topic The topic to publish it to
//    * @param msg The message
//    */
//   Bus publishLocal(String topic, Object msg);
// 
//   /**
//    * Send a message
//    *
//    * @param topic The topic to send it to
//    * @param msg The message
//    * @param replyHandler Reply handler will be called when any reply from the recipient is received
//    */
//   <T> Bus send(String topic, Object msg, Handler<Message<T>> replyHandler);
// 
//   /**
//    * Send a local message
//    *
//    * @param topic The topic to send it to
//    * @param msg The message
//    * @param replyHandler Reply handler will be called when any reply from the recipient is received
//    */
//   <T> Bus sendLocal(String topic, Object msg, Handler<Message<T>> replyHandler);
// 
//   /**
//    * Set a BusHook on the Bus
//    *
//    * @param hook The hook
//    */
//   Bus setHook(BusHook hook);
// 
//   /**
//    * Registers a handler against the specified topic
//    *
//    * @param topic The topic to register it at
//    * @param handler The handler
//    * @return the handler registration, can be stored in order to unregister the handler later
//    */
//   @SuppressWarnings("rawtypes")
//   Registration subscribe(String topic, Handler<? extends Message> handler);
// 
//   /**
//    * Registers a local handler against the specified topic. The handler info won't be propagated
//    * across the cluster
//    *
//    * @param topic The topic to register it at
//    * @param handler The handler
//    */
//   @SuppressWarnings("rawtypes")
//   Registration subscribeLocal(String topic, Handler<? extends Message> handler);
// }
// 
// Path: src/main/java/com/goodow/realtime/channel/Message.java
// @JsType
// public interface Message<T> {
//   /**
//    * The body of the message
//    */
//   T body();
// 
//   /**
//    * Signal that processing of this message failed. If the message was sent specifying a result
//    * handler the handler will be called with a failure corresponding to the failure code and message
//    * specified here
//    *
//    * @param failureCode A failure code to pass back to the sender
//    * @param msg A message to pass back to the sender
//    */
//   void fail(int failureCode, String msg);
// 
//   /**
//    * @return Whether this message originated in the local session.
//    */
//   boolean isLocal();
// 
//   /**
//    * Reply to this message. If the message was sent specifying a reply handler, that handler will be
//    * called when it has received a reply. If the message wasn't sent specifying a receipt handler
//    * this method does nothing.
//    */
//   @JsNoExport
//   void reply(Object msg);
// 
//   /**
//    * The same as {@code reply(Object msg)} but you can specify handler for the reply - i.e. to
//    * receive the reply to the reply.
//    */
//   @SuppressWarnings("hiding")
//   <T> void reply(Object msg, Handler<Message<T>> replyHandler);
// 
//   /**
//    * The reply topic (if any)
//    */
//   String replyTopic();
// 
//   /**
//    * The topic the message was sent to
//    */
//   String topic();
// }
// 
// Path: src/main/java/com/goodow/realtime/core/Handler.java
// public interface Handler<E> {
// 
//   /**
//    * Something has happened, so handle it.
//    */
//   void handle(E event);
// }


import com.goodow.realtime.channel.Message;
import com.goodow.realtime.core.Handler;
import com.goodow.realtime.channel.Bus;
  @Override
  public void fail(int failureCode, String msg) {
    // sendReply(new ReplyException(ReplyFailure.RECIPIENT_FAILURE, failureCode, message), null);
  }

  @Override
  public boolean isLocal() {
    return local;
  }

  @Override
  public void reply(Object msg) {
    sendReply(msg, null);
  }

  @Override
  public <T> void reply(Object msg, Handler<Message<T>> replyHandler) {
    sendReply(msg, replyHandler);
  }

  @Override
  public String replyTopic() {
    return replyTopic;
  }

  @Override
  public String toString() {
    return body == null ? null : body.toString();
  }

// Path: src/main/java/com/goodow/realtime/channel/Bus.java
// @JsType
// public interface Bus {
//   String ON_OPEN = "@realtime/bus/onOpen";
//   String ON_CLOSE = "@realtime/bus/onClose";
//   String ON_ERROR = "@realtime/bus/onError";
// 
//   /**
//    * Close the Bus and release all resources.
//    */
//   void close();
// 
//   /* The state of the Bus. */
//   State getReadyState();
// 
//   /* Returns the session ID used by this bus. */
//   String getSessionId();
// 
//   /**
//    * Publish a message
//    *
//    * @param topic The topic to publish it to
//    * @param msg The message
//    */
//   Bus publish(String topic, Object msg);
// 
//   /**
//    * Publish a local message
//    *
//    * @param topic The topic to publish it to
//    * @param msg The message
//    */
//   Bus publishLocal(String topic, Object msg);
// 
//   /**
//    * Send a message
//    *
//    * @param topic The topic to send it to
//    * @param msg The message
//    * @param replyHandler Reply handler will be called when any reply from the recipient is received
//    */
//   <T> Bus send(String topic, Object msg, Handler<Message<T>> replyHandler);
// 
//   /**
//    * Send a local message
//    *
//    * @param topic The topic to send it to
//    * @param msg The message
//    * @param replyHandler Reply handler will be called when any reply from the recipient is received
//    */
//   <T> Bus sendLocal(String topic, Object msg, Handler<Message<T>> replyHandler);
// 
//   /**
//    * Set a BusHook on the Bus
//    *
//    * @param hook The hook
//    */
//   Bus setHook(BusHook hook);
// 
//   /**
//    * Registers a handler against the specified topic
//    *
//    * @param topic The topic to register it at
//    * @param handler The handler
//    * @return the handler registration, can be stored in order to unregister the handler later
//    */
//   @SuppressWarnings("rawtypes")
//   Registration subscribe(String topic, Handler<? extends Message> handler);
// 
//   /**
//    * Registers a local handler against the specified topic. The handler info won't be propagated
//    * across the cluster
//    *
//    * @param topic The topic to register it at
//    * @param handler The handler
//    */
//   @SuppressWarnings("rawtypes")
//   Registration subscribeLocal(String topic, Handler<? extends Message> handler);
// }
// 
// Path: src/main/java/com/goodow/realtime/channel/Message.java
// @JsType
// public interface Message<T> {
//   /**
//    * The body of the message
//    */
//   T body();
// 
//   /**
//    * Signal that processing of this message failed. If the message was sent specifying a result
//    * handler the handler will be called with a failure corresponding to the failure code and message
//    * specified here
//    *
//    * @param failureCode A failure code to pass back to the sender
//    * @param msg A message to pass back to the sender
//    */
//   void fail(int failureCode, String msg);
// 
//   /**
//    * @return Whether this message originated in the local session.
//    */
//   boolean isLocal();
// 
//   /**
//    * Reply to this message. If the message was sent specifying a reply handler, that handler will be
//    * called when it has received a reply. If the message wasn't sent specifying a receipt handler
//    * this method does nothing.
//    */
//   @JsNoExport
//   void reply(Object msg);
// 
//   /**
//    * The same as {@code reply(Object msg)} but you can specify handler for the reply - i.e. to
//    * receive the reply to the reply.
//    */
//   @SuppressWarnings("hiding")
//   <T> void reply(Object msg, Handler<Message<T>> replyHandler);
// 
//   /**
//    * The reply topic (if any)
//    */
//   String replyTopic();
// 
//   /**
//    * The topic the message was sent to
//    */
//   String topic();
// }
// 
// Path: src/main/java/com/goodow/realtime/core/Handler.java
// public interface Handler<E> {
// 
//   /**
//    * Something has happened, so handle it.
//    */
//   void handle(E event);
// }


// Path: src/main/java/com/goodow/realtime/channel/impl/MessageImpl.java
import com.goodow.realtime.channel.Message;
import com.goodow.realtime.core.Handler;
import com.goodow.realtime.channel.Bus;

  @Override
  public void fail(int failureCode, String msg) {
    // sendReply(new ReplyException(ReplyFailure.RECIPIENT_FAILURE, failureCode, message), null);
  }

  @Override
  public boolean isLocal() {
    return local;
  }

  @Override
  public void reply(Object msg) {
    sendReply(msg, null);
  }

  @Override
  public <T> void reply(Object msg, Handler<Message<T>> replyHandler) {
    sendReply(msg, replyHandler);
  }

  @Override
  public String replyTopic() {
    return replyTopic;
  }

  @Override
  public String toString() {
    return body == null ? null : body.toString();
  }

  private <T> void sendReply(Object msg, Handler<Message<T>> replyHandler) {