//exec pid function func Exec(cmd *common.RequestData, c *online.Client) { //没有登陆就必须登陆系统,小于等于0的协议不需要登陆。 if cmd.Pid <= 0 { pid[cmd.Pid](cmd, c) } else if !c.IsLogin { cmd := common.ResponseData{1, 0, "need login", nil} c.Send(&cmd) } else { if p, ok := pid[cmd.Pid]; ok { p(cmd, c) } else { pidok(cmd, c) } } }
//write pid to responseout ResponseData func writepid(c *online.Client, cmd *common.RequestData, status int, result interface{}) { out := common.ResponseData{cmd.Pid, status, result, cmd.Param} c.Send(&out) }