package msg import ( "rocommon" "rocommon/service" "rocommon/util" "roserver/baseserver" "roserver/baseserver/model" gmmodel "roserver/gmweb/model" "roserver/serverproto" "runtime/debug" "strconv" ) //other service func init() { //serverproto.Handle_GMWEB_SSWebGMAddMailAck = model.HandleBackendMessage(func(ev rocommon.ProcEvent, cliId model.ClientID) { // msg := ev.Msg().(*serverproto.SSWebGMAddMailAck) // util.InfoF("SSWebGMAddMailAck msgid=%v", msg) // // model2.GetMailUpdateMag().AttachMail2Update() //}) serverproto.Handle_GMWEB_CSGiftRewardReq = model.HandleBackendMessage(func(ev rocommon.ProcEvent, cliId model.ClientID) { msg := ev.Msg().(*serverproto.CSGiftRewardReq) util.InfoF("uid=%v CSGiftRewardReq msg=%v", msg.Uuid, msg) //model2.GetMailUpdateMag().AttachMail2Update() uuid := msg.Uuid uidStr := strconv.FormatUint(uuid, 10) zoneStr := strconv.Itoa(service.GetServiceConfig().Node.Zone) urlPath := "?code=" + msg.GiftCode + "&uid=" + uidStr + "&serverid=" + zoneStr go func() { defer func() { //打印奔溃信息 if err := recover(); err != nil { util.InfoF("onError data=%v \n%s\n", err, string(debug.Stack())) } }() tmpRequest := &rocommon.HTTPRequest{} tmpRequest.ReqCodecName = "httpjson" //tmpRequest.ReqMsg = OpenIdServeNode{ // ServerId: zoneId, // HeadId: headId, // Level: level, //默认1级 // RecordTime: uint32(util.GetTimeSeconds()), //} tmpRequest.ResMsg = &gmmodel.GiftSt{} parm := gmmodel.GetHttpNodeParam() httpNode := baseserver.CreateHttpConnector(parm) err := httpNode.(rocommon.HTTPConnector).Request("GET", urlPath, tmpRequest) if err != nil { util.InfoF("uid=%v http Request err=%v", uidStr, err) ackMsg := &serverproto.SCGiftRewardAck{ Error: int32(serverproto.ErrorCode_ERROR_GIFT_CODE_USE_FAIL), Uuid: uuid, } gmmodel.SendSocial(ackMsg) return } //error //1礼包吗已经使用 //2礼包吗已经过期 //3 没有找到礼包吗 util.InfoF("uid=%v CSGiftRewardReq msg=%v res=%v", uidStr, msg, tmpRequest.ResMsg) ackMsg := &serverproto.SCGiftRewardAck{ Error: int32(tmpRequest.ResMsg.(*gmmodel.GiftSt).Error), Uuid: uuid, } if 0 == ackMsg.Error { for _, data := range tmpRequest.ResMsg.(*gmmodel.GiftSt).Content { itemId, _ := model.Str2Num(data.ItemId) itemCount, _ := model.Str2Num(data.ItemCount) ackMsg.RewardList = append(ackMsg.RewardList, &serverproto.KeyValueType{ Key: int32(itemId), Value: int32(itemCount), }) } } gmmodel.SendSocial(ackMsg) }() }) serverproto.Handle_GMWEB_SSWebGMChatMsgNtf = model.HandleBackendMessage(func(ev rocommon.ProcEvent, cliId model.ClientID) { msg := ev.Msg().(*serverproto.SSWebGMChatMsgNtf) util.InfoF("uid=%v SSWebGMChatMsgNtf msg=%v", msg.Uid, msg) gmmodel.GetChatUpdateMag().AddChatMsg(msg) }) }