func()

in game/go-server-game/pkg/provider.go [62:93]


func (p *BasketballService) Score(ctx context.Context, uid, score string) (*pojo.Result, error) {
	logger.Infof("message: %#v, %#v", uid, score)
	var (
		info = &pojo.Info{}
		ok   bool
	)

	// auto reply the same message
	rsp, err := GateBasketball.Send(context.TODO(), uid, score)
	if err != nil {
		logger.Errorf("send fail: %#s", err.Error())
		return &pojo.Result{Code: 1, Msg: err.Error()}, err
	}

	fmt.Println("receive data from gate:", rsp)

	if info, ok = userMap[uid]; !ok {
		info = &pojo.Info{
			Name: uid,
		}
		userMap[uid] = info
		logger.Error("user data not found")
		return &pojo.Result{Code: 1, Msg: "user data not found", Data: map[string]interface{}{}}, nil
	}
	intSource, err := strconv.Atoi(score)
	if err != nil {
		logger.Error(err.Error())
	}
	info.Score += intSource

	return &pojo.Result{Code: 0, Msg: "θΏ›ηƒζˆεŠŸ", Data: map[string]interface{}{"to": uid, "score": info.Score}}, nil
}