package internal

import (
	"reflect"
	"server/game"
	"server/msg"

	"github.com/name5566/leaf/gate"
	"github.com/name5566/leaf/log"
)

func handleMsg(m interface{}, h interface{}) {
	skeleton.RegisterChanRPC(reflect.TypeOf(m), h)
}

func init() {
	handleMsg(&msg.ResLogin{}, loginHandler)
}

func loginHandler(args []interface{}) {
	// agent := args[1].(gate.Agent)
	m := args[0].(*msg.ResLogin)
	// 消息的发送者
	a := args[1].(gate.Agent)

	log.Debug("loginHandler: %v", args)
	game.ChanRPC.Go("handleAuth", m, a)
}
