Gogs 5 months ago
parent
commit
fbcf06a71b
3 changed files with 14 additions and 8 deletions
  1. 1 1
      bin/client_msg/common.proto
  2. 8 2
      src/server/game/internal/chanrpc.go
  3. 5 5
      src/server/msg/common.pb.go

+ 1 - 1
bin/client_msg/common.proto

@@ -4,7 +4,7 @@ option go_package = "./msg";
 
 //登录
 message ResLogin {
-  string openId = 1;
+  string userId = 1;
   string nikeName = 2;
 }
 //登录 响应

+ 8 - 2
src/server/game/internal/chanrpc.go

@@ -1,6 +1,7 @@
 package internal
 
 import (
+	"server/msg"
 	"time"
 
 	"github.com/name5566/leaf/gate"
@@ -28,7 +29,7 @@ var (
 	// 未认证连接池
 	pendingConns = make(map[gate.Agent]*PendingConn)
 	// 已认证用户
-	authedUsers = make(map[int64]gate.Agent) // key: userID
+	authedUsers = make(map[string]gate.Agent) // key: userID
 )
 
 func rpcNewAgent(args []interface{}) {
@@ -59,7 +60,12 @@ func rpcCloseAgent(args []interface{}) {
 }
 
 // 处理认证消息
-func handleAuth(agent gate.Agent, userID int64) {
+func handleAuth(args []interface{}) {
+
+	m := args[0].(*msg.ResLogin)
+	userID := m.UserId
+	agent := args[1].(gate.Agent)
+
 	// 找到未认证连接
 	if pending, exists := pendingConns[agent]; exists {
 		// 认证成功,移动到已认证池

+ 5 - 5
src/server/msg/common.pb.go

@@ -26,7 +26,7 @@ type ResLogin struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	OpenId   string `protobuf:"bytes,1,opt,name=openId,proto3" json:"openId,omitempty"`
+	UserId   string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"`
 	NikeName string `protobuf:"bytes,2,opt,name=nikeName,proto3" json:"nikeName,omitempty"`
 }
 
@@ -62,9 +62,9 @@ func (*ResLogin) Descriptor() ([]byte, []int) {
 	return file_common_proto_rawDescGZIP(), []int{0}
 }
 
-func (x *ResLogin) GetOpenId() string {
+func (x *ResLogin) GetUserId() string {
 	if x != nil {
-		return x.OpenId
+		return x.UserId
 	}
 	return ""
 }
@@ -255,8 +255,8 @@ var File_common_proto protoreflect.FileDescriptor
 
 var file_common_proto_rawDesc = []byte{
 	0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3e,
-	0x0a, 0x08, 0x52, 0x65, 0x73, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x70,
-	0x65, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x70, 0x65, 0x6e,
+	0x0a, 0x08, 0x52, 0x65, 0x73, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73,
+	0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72,
 	0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x6b, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02,
 	0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x6b, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x7f,
 	0x0a, 0x08, 0x52, 0x65, 0x71, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69,