func (c *Client) runMethod(method *Method, args *dnode.Partial) {
	var (
		callFunc func(interface{}, *Error)
		request  *Request
	)
	defer func() {
		if r := recover(); r != nil {
			debug.PrintStack()
			kiteErr := createError(request, r)
			c.LocalKite.Log.Error(kiteErr.Error())  
			callFunc(nil, kiteErr)
		}
	}()
	request, callFunc = c.newRequest(method.name, args)
	if method.authenticate {
		if err := request.authenticate(); err != nil {
			callFunc(nil, createError(request, err))
			return
		}
	} else {
		request.Username = request.Client.Kite.Username
	}
	method.mu.Lock()
	if !method.initialized {
		method.preHandlers = append(method.preHandlers, c.LocalKite.preHandlers...)
		method.postHandlers = append(method.postHandlers, c.LocalKite.postHandlers...)
		method.finalFuncs = append(method.finalFuncs, c.LocalKite.finalFuncs...)
		method.initialized = true
	}
	method.mu.Unlock()
	if method.bucket != nil && method.bucket.TakeAvailable(1) == 0 {
		callFunc(nil, &Error{
			Type:      "requestLimitError",
			Message:   "The maximum request rate is exceeded.",
			RequestID: request.ID,
		})
		return
	}
	result, err := method.ServeKite(request)
	callFunc(result, createError(request, err))
}
runMethod is called when a method is received from remote Kite.
package kite
import (
	"context"
	"errors"
	"fmt"
	"runtime/debug"
	"time"
	"github.com/dgrijalva/jwt-go"
	"github.com/koding/cache"
	"github.com/koding/kite/dnode"
	"github.com/koding/kite/kitekey"
	"github.com/koding/kite/protocol"
	"github.com/koding/kite/sockjsclient"
	"github.com/koding/kite/utils"
)
type Request struct {
	ID string
	Method string
	Username string
	Args *dnode.Partial
	LocalKite *Kite
	Client *Client
	Auth *Auth
	Context context.Context
}
type Response struct {
	Error  *Error      `json:"error" dnode:"-"`
	Result interface{} `json:"result"`
}