Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
90675a76d7
0
bin/bulid_linux.sh → bin/build_linux.sh
Normal file → Executable file
0
bin/bulid_linux.sh → bin/build_linux.sh
Normal file → Executable file
BIN
bin/gateway
BIN
bin/gateway
Binary file not shown.
BIN
bin/mainte
BIN
bin/mainte
Binary file not shown.
@ -25,7 +25,7 @@
|
||||
|
||||
}
|
||||
stop(){
|
||||
echo "stopping..."
|
||||
echo "stopping $SERVICE..."
|
||||
kill -9 `cat $SERVICE.pid`
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
@ -56,4 +56,4 @@
|
||||
*) echo "Usage: $0 {start|stop|restart|status}" ;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
BIN
bin/worker
BIN
bin/worker
Binary file not shown.
@ -48,14 +48,17 @@ const (
|
||||
|
||||
//RPC服务接口定义处
|
||||
const ( //Rpc
|
||||
Rpc_GatewayRoute core.Rpc_Key = "Rpc_GatewayRoute" //网关路由
|
||||
Rpc_GatewayAgentBind core.Rpc_Key = "Rpc_GatewayAgentBind" //代理绑定 绑定用户Id
|
||||
Rpc_GatewayAgentUnBind core.Rpc_Key = "Rpc_GatewayAgentUnBind" //代理解绑 解绑用户Id
|
||||
Rpc_GatewayAgentSendMsg core.Rpc_Key = "Rpc_GatewayAgentSendMsg" //代理发送消息 向用户发送消息
|
||||
Rpc_GatewaySendBatchMsg core.Rpc_Key = "Rpc_GatewaySendBatchMsg" //向多个用户发送消息
|
||||
Rpc_GatewaySendRadioMsg core.Rpc_Key = "Rpc_GatewaySendRadioMsg" //广播消息
|
||||
Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接
|
||||
Rpc_NoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线
|
||||
//Gateway
|
||||
Rpc_GatewayRoute core.Rpc_Key = "Rpc_GatewayRoute" //网关路由
|
||||
Rpc_GatewayAgentBind core.Rpc_Key = "Rpc_GatewayAgentBind" //代理绑定 绑定用户Id
|
||||
Rpc_GatewayAgentUnBind core.Rpc_Key = "Rpc_GatewayAgentUnBind" //代理解绑 解绑用户Id
|
||||
Rpc_GatewayAgentSendMsg core.Rpc_Key = "Rpc_GatewayAgentSendMsg" //代理发送消息 向用户发送消息
|
||||
Rpc_GatewaySendBatchMsg core.Rpc_Key = "Rpc_GatewaySendBatchMsg" //向多个用户发送消息
|
||||
Rpc_GatewaySendRadioMsg core.Rpc_Key = "Rpc_GatewaySendRadioMsg" //广播消息
|
||||
Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接
|
||||
Rpc_GatewayNoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线
|
||||
//Chat
|
||||
Rpc_ReleaseSystemMessage core.Rpc_Key = "Rpc_ReleaseSystemMessage" //发布系统消息
|
||||
)
|
||||
|
||||
//事件类型定义处
|
||||
|
@ -100,13 +100,6 @@ func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Me
|
||||
log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname)
|
||||
return
|
||||
}
|
||||
// if agrType.Kind() != reflect.Ptr {
|
||||
// return
|
||||
// }
|
||||
// if !this.isExportedOrBuiltinType(agrType) {
|
||||
// return
|
||||
// }
|
||||
|
||||
if mtype.NumOut() != 2 {
|
||||
log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname)
|
||||
return
|
||||
|
@ -41,11 +41,18 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq)
|
||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
return
|
||||
}
|
||||
if equipments[i].HeroId != "" { //装备已经有宿主了
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
|
||||
if confs[i], err = this.module.configure.GetEquipmentConfigureById(equipments[i].CId); err != nil {
|
||||
log.Errorf("Equip_Check err:%v", err)
|
||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
return
|
||||
}
|
||||
} else {
|
||||
equipments[i] = nil
|
||||
}
|
||||
}
|
||||
//获取英雄数据
|
||||
@ -113,12 +120,15 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq)
|
||||
}
|
||||
}
|
||||
//更新装备数据加成
|
||||
if code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); code == pb.ErrorCode_Success {
|
||||
if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil {
|
||||
log.Errorf("Equip err%v", err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
if code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); code != pb.ErrorCode_Success {
|
||||
log.Errorf("Equip ModuleHero UpdateEquipment code%v", code)
|
||||
return
|
||||
}
|
||||
//同步数据
|
||||
if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil {
|
||||
log.Errorf("Equip err%v", err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "equip", &pb.EquipmentEquipResp{Equipments: updatequipment})
|
||||
return
|
||||
|
@ -44,7 +44,7 @@ func (this *AgentMgrComp) DisConnect(a IAgent) {
|
||||
this.agents.Delete(a.SessionId())
|
||||
if a.UserId() != "" { //登录用户 通知业务服务处理玩家离线相关
|
||||
reply := &pb.RPCMessageReply{}
|
||||
if _, err := this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Worker, a.WorkerId()), string(comm.Rpc_NoticeUserClose), &pb.NoticeUserCloseReq{
|
||||
if _, err := this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Worker, a.WorkerId()), string(comm.Rpc_GatewayNoticeUserClose), &pb.NoticeUserCloseReq{
|
||||
Ip: a.IP(),
|
||||
ServiceTag: this.service.GetTag(),
|
||||
GatewayServiceId: this.service.GetId(),
|
||||
@ -54,7 +54,7 @@ func (this *AgentMgrComp) DisConnect(a IAgent) {
|
||||
log.Errorf("uId:%s Rpc_NoticeUserClose err:%v", a.UserId(), err)
|
||||
}
|
||||
//推送跨服集群处理
|
||||
if _, err := this.service.AcrossClusterRpcGo(context.Background(), this.options.SpanServiceTag, comm.Service_Worker, string(comm.Rpc_NoticeUserClose), &pb.NoticeUserCloseReq{
|
||||
if _, err := this.service.AcrossClusterRpcGo(context.Background(), this.options.SpanServiceTag, comm.Service_Worker, string(comm.Rpc_GatewayNoticeUserClose), &pb.NoticeUserCloseReq{
|
||||
Ip: a.IP(),
|
||||
ServiceTag: this.service.GetTag(),
|
||||
GatewayServiceId: this.service.GetId(),
|
||||
|
@ -4,6 +4,9 @@ import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/core/cbase"
|
||||
"go_dreamfactory/lego/sys/gin"
|
||||
"go_dreamfactory/lego/sys/gin/engine"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -22,8 +25,30 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core
|
||||
this.options = options.(*Options)
|
||||
this.module = module.(*GM)
|
||||
this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port))
|
||||
this.gin.POST("/register", this.Register)
|
||||
this.gin.GET("/serverlist", this.ServerList)
|
||||
this.gin.GET("/createnotify", this.CreateNotify)
|
||||
this.suitableMethods() //发射注册api
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Api_Comp) suitableMethods() {
|
||||
typ := reflect.TypeOf(this)
|
||||
vof := reflect.ValueOf(this)
|
||||
for m := 0; m < typ.NumMethod(); m++ {
|
||||
method := typ.Method(m)
|
||||
mname := method.Name
|
||||
mtype := method.Type
|
||||
if method.PkgPath != "" {
|
||||
continue
|
||||
}
|
||||
if mtype.NumIn() != 2 {
|
||||
continue
|
||||
}
|
||||
context := mtype.In(1)
|
||||
if context.String() != "*engine.Context" {
|
||||
continue
|
||||
}
|
||||
if mtype.NumOut() != 0 {
|
||||
continue
|
||||
}
|
||||
this.gin.POST(strings.ToLower(mname), vof.MethodByName(mname).Interface().(func(*engine.Context)))
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp,
|
||||
|
||||
//组件启动时注册rpc服务监听
|
||||
func (this *SCompGateRoute) Start() (err error) {
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_NoticeUserClose), this.NoticeUserClose) //注册用户离线通知
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_GatewayNoticeUserClose), this.NoticeUserClose) //注册用户离线通知
|
||||
err = this.ServiceCompBase.Start()
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user