feat sn 改成 int64

This commit is contained in:
2026-01-30 11:53:20 +08:00
parent 427fca7ed1
commit 5dc5391b07
20 changed files with 189 additions and 182 deletions

View File

@@ -6,7 +6,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func GatewayNewClient(sid ...string) (grpc_pb.GatewayClient, error) {
func GatewayNewClient(sid ...int64) (grpc_pb.GatewayClient, error) {
c, err := discover.FindServer(common.KeyDiscoverGateway, sid...)
if err != nil {
return nil, err
@@ -14,8 +14,8 @@ func GatewayNewClient(sid ...string) (grpc_pb.GatewayClient, error) {
return grpc_pb.NewGatewayClient(c), nil
}
func GatewayNewBroadcastClient() map[string]grpc_pb.GatewayClient {
clientM := make(map[string]grpc_pb.GatewayClient)
func GatewayNewBroadcastClient() map[int64]grpc_pb.GatewayClient {
clientM := make(map[int64]grpc_pb.GatewayClient)
connM := discover.FindServerAll(common.KeyDiscoverGateway)
for sid, conn := range connM {
clientM[sid] = grpc_pb.NewGatewayClient(conn)

View File

@@ -7,7 +7,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func QgdzsNewClient(sid ...string) (grpc_pb.QgdzsClient, error) {
func QgdzsNewClient(sid ...int64) (grpc_pb.QgdzsClient, error) {
c, err := discover.FindServer(common.KeyDiscoverQgdzs, sid...)
if err != nil {
return nil, err

View File

@@ -7,7 +7,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func SceneNewClient(sid ...string) (grpc_pb.SceneClient, error) {
func SceneNewClient(sid ...int64) (grpc_pb.SceneClient, error) {
c, err := discover.FindServer(common.KeyDiscoverScene, sid...)
if err != nil {
return nil, err
@@ -23,8 +23,8 @@ func SceneNewClientLB() (grpc_pb.SceneClient, error) {
return grpc_pb.NewSceneClient(c), nil
}
func SceneNewBroadcastClient() map[string]grpc_pb.SceneClient {
clientM := make(map[string]grpc_pb.SceneClient)
func SceneNewBroadcastClient() map[int64]grpc_pb.SceneClient {
clientM := make(map[int64]grpc_pb.SceneClient)
connM := discover.FindServerAll(common.KeyDiscoverScene)
for sid, conn := range connM {
clientM[sid] = grpc_pb.NewSceneClient(conn)

View File

@@ -7,7 +7,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func UserNewClient(sid ...string) (grpc_pb.UserClient, error) {
func UserNewClient(sid ...int64) (grpc_pb.UserClient, error) {
c, err := discover.FindServer(common.KeyDiscoverUser, sid...)
if err != nil {
return nil, err

View File

@@ -2,10 +2,10 @@ package grpc_client
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"strconv"
"sync"
)
@@ -22,7 +22,7 @@ type gatewayStream struct {
stream grpc.ClientStream
}
func findGatewayBySID(sid string, fun GatewayFun) (*gatewayStream, error) {
func findGatewayBySID(sid int64, fun GatewayFun) (*gatewayStream, error) {
key := gatewayKey(sid, fun)
if v, ok := gatewayServer.Load(key); ok {
@@ -53,7 +53,7 @@ func findGatewayBySID(sid string, fun GatewayFun) (*gatewayStream, error) {
return ss, nil
}
func SendMessageToGateway(sid string, fun GatewayFun, msg proto.Message, re ...bool) error {
func SendMessageToGateway(sid int64, fun GatewayFun, msg proto.Message, re ...bool) error {
ss, err := findGatewayBySID(sid, fun)
if err != nil {
return err
@@ -78,6 +78,6 @@ func SendMessageToGateway(sid string, fun GatewayFun, msg proto.Message, re ...b
return nil
}
func gatewayKey(sid string, fun GatewayFun) string {
return sid + "-" + strconv.Itoa(int(fun))
func gatewayKey(sid int64, fun GatewayFun) string {
return fmt.Sprintf("%v-%v", sid, fun)
}

View File

@@ -2,10 +2,10 @@ package grpc_client
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"strconv"
"sync"
)
@@ -22,7 +22,7 @@ type sceneStream struct {
stream grpc.ClientStream
}
func findSceneBySID(sid string, fun SceneFun) (*sceneStream, error) {
func findSceneBySID(sid int64, fun SceneFun) (*sceneStream, error) {
key := sceneKey(sid, fun)
if v, ok := sceneServer.Load(key); ok {
@@ -53,7 +53,7 @@ func findSceneBySID(sid string, fun SceneFun) (*sceneStream, error) {
return ss, nil
}
func SendMessageToScene(sid string, fun SceneFun, msg proto.Message, re ...bool) error {
func SendMessageToScene(sid int64, fun SceneFun, msg proto.Message, re ...bool) error {
ss, err := findSceneBySID(sid, fun)
if err != nil {
return err
@@ -78,6 +78,6 @@ func SendMessageToScene(sid string, fun SceneFun, msg proto.Message, re ...bool)
return nil
}
func sceneKey(sid string, fun SceneFun) string {
return sid + "-" + strconv.Itoa(int(fun))
func sceneKey(sid int64, fun SceneFun) string {
return fmt.Sprintf("%v-%v", sid, fun)
}