// Path: src/main/java/org/msgpack/rpc/Request.java
// public class Request implements Callback<Object> {
//     private MessageSendable channel; // TODO #SF synchronized?
//     private int msgid;
//     private String method;
//     private Value args;
// 
//     public Request(MessageSendable channel, int msgid, String method, Value args) {
//         this.channel = channel;
//         this.msgid = msgid;
//         this.method = method;
//         this.args = args;
//     }
// 
//     public Request(String method, Value args) {
//         this.channel = null;
//         this.msgid = 0;
//         this.method = method;
//         this.args = args;
//     }
// 
//     public String getMethodName() {
//         return method;
//     }
// 
//     public Value getArguments() {
//         return args;
//     }
// 
//     public int getMessageID() {
//         return msgid;
//     }
// 
//     public void sendResult(Object result) {
//         sendResponse(result, null);
//     }
// 
//     public void sendError(Object error) {
//         sendResponse(null, error);
//     }
// 
//     public void sendError(Object error, Object data) {
//         sendResponse(data, error);
//     }
// 
//     public synchronized void sendResponse(Object result, Object error) {
//         if (channel == null) {
//             return;
//         }
//         ResponseMessage msg = new ResponseMessage(msgid, error, result);
//         channel.sendMessage(msg);
//         channel = null;
//     }
// }


import org.msgpack.rpc.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.msgpack.rpc.dispatcher;


/**
 * For debug.
 * Measures dispatch time.
 *
 * User: takeshita
 * Create: 12/06/15 0:53
 */
public class StopWatchDispatcher implements Dispatcher {

    Dispatcher innerDispatcher;

    private final static Logger logger = LoggerFactory.getLogger(StopWatchDispatcher.class);

    private boolean verbose = true;

    public boolean isVerbose() {
        return verbose;
    }

    public void setVerbose(boolean verbose) {
        this.verbose = verbose;
    }

    public StopWatchDispatcher(Dispatcher inner) {
        this.innerDispatcher = inner;
    }

// Path: src/main/java/org/msgpack/rpc/Request.java
// public class Request implements Callback<Object> {
//     private MessageSendable channel; // TODO #SF synchronized?
//     private int msgid;
//     private String method;
//     private Value args;
// 
//     public Request(MessageSendable channel, int msgid, String method, Value args) {
//         this.channel = channel;
//         this.msgid = msgid;
//         this.method = method;
//         this.args = args;
//     }
// 
//     public Request(String method, Value args) {
//         this.channel = null;
//         this.msgid = 0;
//         this.method = method;
//         this.args = args;
//     }
// 
//     public String getMethodName() {
//         return method;
//     }
// 
//     public Value getArguments() {
//         return args;
//     }
// 
//     public int getMessageID() {
//         return msgid;
//     }
// 
//     public void sendResult(Object result) {
//         sendResponse(result, null);
//     }
// 
//     public void sendError(Object error) {
//         sendResponse(null, error);
//     }
// 
//     public void sendError(Object error, Object data) {
//         sendResponse(data, error);
//     }
// 
//     public synchronized void sendResponse(Object result, Object error) {
//         if (channel == null) {
//             return;
//         }
//         ResponseMessage msg = new ResponseMessage(msgid, error, result);
//         channel.sendMessage(msg);
//         channel = null;
//     }
// }


// Path: src/main/java/org/msgpack/rpc/dispatcher/StopWatchDispatcher.java
import org.msgpack.rpc.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

package org.msgpack.rpc.dispatcher;


/**
 * For debug.
 * Measures dispatch time.
 *
 * User: takeshita
 * Create: 12/06/15 0:53
 */
public class StopWatchDispatcher implements Dispatcher {

    Dispatcher innerDispatcher;

    private final static Logger logger = LoggerFactory.getLogger(StopWatchDispatcher.class);

    private boolean verbose = true;

    public boolean isVerbose() {
        return verbose;
    }

    public void setVerbose(boolean verbose) {
        this.verbose = verbose;
    }

    public StopWatchDispatcher(Dispatcher inner) {
        this.innerDispatcher = inner;
    }

    public void dispatch(Request request) throws Exception {