chore(vscode): 更新调试配置并删除无用的 API 代码

- 在 .vscode/launch.json 中添加了新的 Go 调试配置项
- 删除了 blazing/common/api 目录下未使用的 Kick.pb.go 和 Quit.pb.go 文件
This commit is contained in:
2025-07-06 19:31:30 +08:00
parent 83ecb90baf
commit 53da82df82
17 changed files with 279 additions and 1453 deletions

10
.vscode/launch.json vendored
View File

@@ -14,13 +14,21 @@
"program": "${workspaceFolder}/login"
},
{
"name": "Launch logic",
"name": "Launch logic1",
"type": "go",
"request": "launch",
"mode": "auto",
"cwd": "${workspaceFolder}",
"args": ["-port=1"],
"program": "${workspaceFolder}/logic"
}, {
"name": "Launch logic2",
"type": "go",
"request": "launch",
"mode": "auto",
"cwd": "${workspaceFolder}",
"args": ["-port=2"],
"program": "${workspaceFolder}/logic"
},
{
"name": "Launch login-tcp",

View File

@@ -1,154 +0,0 @@
// 1.proto
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.2
// protoc v4.25.3
// source: manifest/proto/Kick.proto
package api
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 踢人服务
type Kick struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name int32 `protobuf:"varint,1,opt,name=name,proto3" json:"name,omitempty"` //服务器端口
Age int32 `protobuf:"varint,2,opt,name=age,proto3" json:"age,omitempty"` //
}
func (x *Kick) Reset() {
*x = Kick{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_Kick_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Kick) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Kick) ProtoMessage() {}
func (x *Kick) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_Kick_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Kick.ProtoReflect.Descriptor instead.
func (*Kick) Descriptor() ([]byte, []int) {
return file_manifest_proto_Kick_proto_rawDescGZIP(), []int{0}
}
func (x *Kick) GetName() int32 {
if x != nil {
return x.Name
}
return 0
}
func (x *Kick) GetAge() int32 {
if x != nil {
return x.Age
}
return 0
}
var File_manifest_proto_Kick_proto protoreflect.FileDescriptor
var file_manifest_proto_Kick_proto_rawDesc = []byte{
0x0a, 0x19, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2f, 0x4b, 0x69, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69,
0x22, 0x2c, 0x0a, 0x04, 0x4b, 0x69, 0x63, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03,
0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x42, 0x14,
0x5a, 0x12, 0x62, 0x6c, 0x61, 0x7a, 0x69, 0x6e, 0x67, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_manifest_proto_Kick_proto_rawDescOnce sync.Once
file_manifest_proto_Kick_proto_rawDescData = file_manifest_proto_Kick_proto_rawDesc
)
func file_manifest_proto_Kick_proto_rawDescGZIP() []byte {
file_manifest_proto_Kick_proto_rawDescOnce.Do(func() {
file_manifest_proto_Kick_proto_rawDescData = protoimpl.X.CompressGZIP(file_manifest_proto_Kick_proto_rawDescData)
})
return file_manifest_proto_Kick_proto_rawDescData
}
var file_manifest_proto_Kick_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_manifest_proto_Kick_proto_goTypes = []any{
(*Kick)(nil), // 0: api.Kick
}
var file_manifest_proto_Kick_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_manifest_proto_Kick_proto_init() }
func file_manifest_proto_Kick_proto_init() {
if File_manifest_proto_Kick_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_manifest_proto_Kick_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*Kick); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_manifest_proto_Kick_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_manifest_proto_Kick_proto_goTypes,
DependencyIndexes: file_manifest_proto_Kick_proto_depIdxs,
MessageInfos: file_manifest_proto_Kick_proto_msgTypes,
}.Build()
File_manifest_proto_Kick_proto = out.File
file_manifest_proto_Kick_proto_rawDesc = nil
file_manifest_proto_Kick_proto_goTypes = nil
file_manifest_proto_Kick_proto_depIdxs = nil
}

View File

@@ -1,153 +0,0 @@
// 1.proto
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.2
// protoc v4.25.3
// source: manifest/proto/Quit.proto
package api
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Person struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Age int32 `protobuf:"varint,2,opt,name=age,proto3" json:"age,omitempty"`
}
func (x *Person) Reset() {
*x = Person{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_Quit_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Person) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Person) ProtoMessage() {}
func (x *Person) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_Quit_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Person.ProtoReflect.Descriptor instead.
func (*Person) Descriptor() ([]byte, []int) {
return file_manifest_proto_Quit_proto_rawDescGZIP(), []int{0}
}
func (x *Person) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Person) GetAge() int32 {
if x != nil {
return x.Age
}
return 0
}
var File_manifest_proto_Quit_proto protoreflect.FileDescriptor
var file_manifest_proto_Quit_proto_rawDesc = []byte{
0x0a, 0x19, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2f, 0x51, 0x75, 0x69, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69,
0x22, 0x2e, 0x0a, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10,
0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65,
0x42, 0x14, 0x5a, 0x12, 0x62, 0x6c, 0x61, 0x7a, 0x69, 0x6e, 0x67, 0x2f, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_manifest_proto_Quit_proto_rawDescOnce sync.Once
file_manifest_proto_Quit_proto_rawDescData = file_manifest_proto_Quit_proto_rawDesc
)
func file_manifest_proto_Quit_proto_rawDescGZIP() []byte {
file_manifest_proto_Quit_proto_rawDescOnce.Do(func() {
file_manifest_proto_Quit_proto_rawDescData = protoimpl.X.CompressGZIP(file_manifest_proto_Quit_proto_rawDescData)
})
return file_manifest_proto_Quit_proto_rawDescData
}
var file_manifest_proto_Quit_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_manifest_proto_Quit_proto_goTypes = []any{
(*Person)(nil), // 0: api.Person
}
var file_manifest_proto_Quit_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_manifest_proto_Quit_proto_init() }
func file_manifest_proto_Quit_proto_init() {
if File_manifest_proto_Quit_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_manifest_proto_Quit_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*Person); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_manifest_proto_Quit_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_manifest_proto_Quit_proto_goTypes,
DependencyIndexes: file_manifest_proto_Quit_proto_depIdxs,
MessageInfos: file_manifest_proto_Quit_proto_msgTypes,
}.Build()
File_manifest_proto_Quit_proto = out.File
file_manifest_proto_Quit_proto_rawDesc = nil
file_manifest_proto_Quit_proto_goTypes = nil
file_manifest_proto_Quit_proto_depIdxs = nil
}

View File

@@ -1,798 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.2
// protoc v3.20.0--rc1
// source: manifest/proto/rpc.proto
package api
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 注册请求 - logic 用户登录后注册
type RegisterUser struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Identity int32 `protobuf:"varint,1,opt,name=identity,proto3" json:"identity,omitempty"` // 客户端身份,进入后保存id->端口 实现通知踢人以及进程退出
UserId int32 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 执行踢人操作的用户id
}
func (x *RegisterUser) Reset() {
*x = RegisterUser{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_rpc_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegisterUser) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterUser) ProtoMessage() {}
func (x *RegisterUser) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_rpc_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterUser.ProtoReflect.Descriptor instead.
func (*RegisterUser) Descriptor() ([]byte, []int) {
return file_manifest_proto_rpc_proto_rawDescGZIP(), []int{0}
}
func (x *RegisterUser) GetIdentity() int32 {
if x != nil {
return x.Identity
}
return 0
}
func (x *RegisterUser) GetUserId() int32 {
if x != nil {
return x.UserId
}
return 0
}
// 注册请求 - B客户端使用此消息向服务器注册
type KickRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 执行踢人操作的用户id
}
func (x *KickRequest) Reset() {
*x = KickRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_rpc_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *KickRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*KickRequest) ProtoMessage() {}
func (x *KickRequest) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_rpc_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use KickRequest.ProtoReflect.Descriptor instead.
func (*KickRequest) Descriptor() ([]byte, []int) {
return file_manifest_proto_rpc_proto_rawDescGZIP(), []int{1}
}
func (x *KickRequest) GetUserId() int32 {
if x != nil {
return x.UserId
}
return 0
}
// 函数描述符
type FunctionDescriptor struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FunctionName string `protobuf:"bytes,1,opt,name=function_name,json=functionName,proto3" json:"function_name,omitempty"` // 函数名称
InputType string `protobuf:"bytes,2,opt,name=input_type,json=inputType,proto3" json:"input_type,omitempty"` // 输入参数类型
OutputType string `protobuf:"bytes,3,opt,name=output_type,json=outputType,proto3" json:"output_type,omitempty"` // 输出参数类型
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` // 函数描述
}
func (x *FunctionDescriptor) Reset() {
*x = FunctionDescriptor{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_rpc_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FunctionDescriptor) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FunctionDescriptor) ProtoMessage() {}
func (x *FunctionDescriptor) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_rpc_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FunctionDescriptor.ProtoReflect.Descriptor instead.
func (*FunctionDescriptor) Descriptor() ([]byte, []int) {
return file_manifest_proto_rpc_proto_rawDescGZIP(), []int{2}
}
func (x *FunctionDescriptor) GetFunctionName() string {
if x != nil {
return x.FunctionName
}
return ""
}
func (x *FunctionDescriptor) GetInputType() string {
if x != nil {
return x.InputType
}
return ""
}
func (x *FunctionDescriptor) GetOutputType() string {
if x != nil {
return x.OutputType
}
return ""
}
func (x *FunctionDescriptor) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
// 注册响应
type RegisterResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // 注册是否成功
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` // 消息描述
RegistrationId string `protobuf:"bytes,3,opt,name=registration_id,json=registrationId,proto3" json:"registration_id,omitempty"` // 注册ID
}
func (x *RegisterResponse) Reset() {
*x = RegisterResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_rpc_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegisterResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterResponse) ProtoMessage() {}
func (x *RegisterResponse) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_rpc_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead.
func (*RegisterResponse) Descriptor() ([]byte, []int) {
return file_manifest_proto_rpc_proto_rawDescGZIP(), []int{3}
}
func (x *RegisterResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
func (x *RegisterResponse) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *RegisterResponse) GetRegistrationId() string {
if x != nil {
return x.RegistrationId
}
return ""
}
// 函数调用请求 - A客户端使用此消息请求调用B的函数
type FunctionCallRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
TargetClientId string `protobuf:"bytes,1,opt,name=target_client_id,json=targetClientId,proto3" json:"target_client_id,omitempty"` // 目标客户端IDB
FunctionName string `protobuf:"bytes,2,opt,name=function_name,json=functionName,proto3" json:"function_name,omitempty"` // 要调用的函数名
Parameters []byte `protobuf:"bytes,3,opt,name=parameters,proto3" json:"parameters,omitempty"` // 序列化后的函数参数
CallId string `protobuf:"bytes,4,opt,name=call_id,json=callId,proto3" json:"call_id,omitempty"` // 调用ID用于关联响应
}
func (x *FunctionCallRequest) Reset() {
*x = FunctionCallRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_rpc_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FunctionCallRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FunctionCallRequest) ProtoMessage() {}
func (x *FunctionCallRequest) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_rpc_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FunctionCallRequest.ProtoReflect.Descriptor instead.
func (*FunctionCallRequest) Descriptor() ([]byte, []int) {
return file_manifest_proto_rpc_proto_rawDescGZIP(), []int{4}
}
func (x *FunctionCallRequest) GetTargetClientId() string {
if x != nil {
return x.TargetClientId
}
return ""
}
func (x *FunctionCallRequest) GetFunctionName() string {
if x != nil {
return x.FunctionName
}
return ""
}
func (x *FunctionCallRequest) GetParameters() []byte {
if x != nil {
return x.Parameters
}
return nil
}
func (x *FunctionCallRequest) GetCallId() string {
if x != nil {
return x.CallId
}
return ""
}
// 函数调用响应 - 从B客户端返回给A客户端
type FunctionCallResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
CallId string `protobuf:"bytes,1,opt,name=call_id,json=callId,proto3" json:"call_id,omitempty"` // 对应请求的调用ID
Success bool `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"` // 调用是否成功
Result []byte `protobuf:"bytes,3,opt,name=result,proto3" json:"result,omitempty"` // 序列化后的返回结果
ErrorMessage string `protobuf:"bytes,4,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` // 错误消息(如果失败)
}
func (x *FunctionCallResponse) Reset() {
*x = FunctionCallResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_rpc_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FunctionCallResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FunctionCallResponse) ProtoMessage() {}
func (x *FunctionCallResponse) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_rpc_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FunctionCallResponse.ProtoReflect.Descriptor instead.
func (*FunctionCallResponse) Descriptor() ([]byte, []int) {
return file_manifest_proto_rpc_proto_rawDescGZIP(), []int{5}
}
func (x *FunctionCallResponse) GetCallId() string {
if x != nil {
return x.CallId
}
return ""
}
func (x *FunctionCallResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
func (x *FunctionCallResponse) GetResult() []byte {
if x != nil {
return x.Result
}
return nil
}
func (x *FunctionCallResponse) GetErrorMessage() string {
if x != nil {
return x.ErrorMessage
}
return ""
}
// 通用消息
type GenericMessage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Types that are assignable to Payload:
//
// *GenericMessage_RegisterRequest
// *GenericMessage_RegisterResponse
// *GenericMessage_FunctionCallRequest
// *GenericMessage_FunctionCallResponse
// *GenericMessage_TextMessage
// *GenericMessage_KickResponse
// *GenericMessage_Sucess
Payload isGenericMessage_Payload `protobuf_oneof:"payload"`
}
func (x *GenericMessage) Reset() {
*x = GenericMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_manifest_proto_rpc_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GenericMessage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GenericMessage) ProtoMessage() {}
func (x *GenericMessage) ProtoReflect() protoreflect.Message {
mi := &file_manifest_proto_rpc_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GenericMessage.ProtoReflect.Descriptor instead.
func (*GenericMessage) Descriptor() ([]byte, []int) {
return file_manifest_proto_rpc_proto_rawDescGZIP(), []int{6}
}
func (m *GenericMessage) GetPayload() isGenericMessage_Payload {
if m != nil {
return m.Payload
}
return nil
}
func (x *GenericMessage) GetRegisterRequest() *RegisterUser {
if x, ok := x.GetPayload().(*GenericMessage_RegisterRequest); ok {
return x.RegisterRequest
}
return nil
}
func (x *GenericMessage) GetRegisterResponse() *RegisterResponse {
if x, ok := x.GetPayload().(*GenericMessage_RegisterResponse); ok {
return x.RegisterResponse
}
return nil
}
func (x *GenericMessage) GetFunctionCallRequest() *FunctionCallRequest {
if x, ok := x.GetPayload().(*GenericMessage_FunctionCallRequest); ok {
return x.FunctionCallRequest
}
return nil
}
func (x *GenericMessage) GetFunctionCallResponse() *FunctionCallResponse {
if x, ok := x.GetPayload().(*GenericMessage_FunctionCallResponse); ok {
return x.FunctionCallResponse
}
return nil
}
func (x *GenericMessage) GetTextMessage() string {
if x, ok := x.GetPayload().(*GenericMessage_TextMessage); ok {
return x.TextMessage
}
return ""
}
func (x *GenericMessage) GetKickResponse() *KickRequest {
if x, ok := x.GetPayload().(*GenericMessage_KickResponse); ok {
return x.KickResponse
}
return nil
}
func (x *GenericMessage) GetSucess() bool {
if x, ok := x.GetPayload().(*GenericMessage_Sucess); ok {
return x.Sucess
}
return false
}
type isGenericMessage_Payload interface {
isGenericMessage_Payload()
}
type GenericMessage_RegisterRequest struct {
RegisterRequest *RegisterUser `protobuf:"bytes,1,opt,name=register_request,json=registerRequest,proto3,oneof"`
}
type GenericMessage_RegisterResponse struct {
RegisterResponse *RegisterResponse `protobuf:"bytes,2,opt,name=register_response,json=registerResponse,proto3,oneof"`
}
type GenericMessage_FunctionCallRequest struct {
FunctionCallRequest *FunctionCallRequest `protobuf:"bytes,3,opt,name=function_call_request,json=functionCallRequest,proto3,oneof"`
}
type GenericMessage_FunctionCallResponse struct {
FunctionCallResponse *FunctionCallResponse `protobuf:"bytes,4,opt,name=function_call_response,json=functionCallResponse,proto3,oneof"`
}
type GenericMessage_TextMessage struct {
TextMessage string `protobuf:"bytes,5,opt,name=text_message,json=textMessage,proto3,oneof"` // 普通文本消息
}
type GenericMessage_KickResponse struct {
KickResponse *KickRequest `protobuf:"bytes,6,opt,name=kick_response,json=kickResponse,proto3,oneof"`
}
type GenericMessage_Sucess struct {
Sucess bool `protobuf:"varint,7,opt,name=sucess,proto3,oneof"`
}
func (*GenericMessage_RegisterRequest) isGenericMessage_Payload() {}
func (*GenericMessage_RegisterResponse) isGenericMessage_Payload() {}
func (*GenericMessage_FunctionCallRequest) isGenericMessage_Payload() {}
func (*GenericMessage_FunctionCallResponse) isGenericMessage_Payload() {}
func (*GenericMessage_TextMessage) isGenericMessage_Payload() {}
func (*GenericMessage_KickResponse) isGenericMessage_Payload() {}
func (*GenericMessage_Sucess) isGenericMessage_Payload() {}
var File_manifest_proto_rpc_proto protoreflect.FileDescriptor
var file_manifest_proto_rpc_proto_rawDesc = []byte{
0x0a, 0x18, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2f, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x22,
0x43, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12,
0x1a, 0x0a, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
0x05, 0x52, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x75,
0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73,
0x65, 0x72, 0x49, 0x64, 0x22, 0x26, 0x0a, 0x0b, 0x4b, 0x69, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x9b, 0x01, 0x0a,
0x12, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70,
0x74, 0x6f, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x75, 0x6e, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x6e, 0x70, 0x75,
0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e,
0x70, 0x75, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x70, 0x75,
0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x75,
0x74, 0x70, 0x75, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63,
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64,
0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x6f, 0x0a, 0x10, 0x52, 0x65,
0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18,
0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x72, 0x65, 0x67,
0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x9d, 0x01, 0x0a, 0x13,
0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74,
0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a,
0x0d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61,
0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65,
0x72, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x61, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20,
0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x61, 0x6c, 0x6c, 0x49, 0x64, 0x22, 0x86, 0x01, 0x0a, 0x14,
0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x61, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x61, 0x6c, 0x6c, 0x49, 0x64, 0x12, 0x18, 0x0a,
0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07,
0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c,
0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12,
0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x22, 0xbc, 0x03, 0x0a, 0x0e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3e, 0x0a, 0x10, 0x72, 0x65, 0x67, 0x69, 0x73,
0x74, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72,
0x55, 0x73, 0x65, 0x72, 0x48, 0x00, 0x52, 0x0f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x44, 0x0a, 0x11, 0x72, 0x65, 0x67, 0x69, 0x73,
0x74, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65,
0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x10, 0x72, 0x65, 0x67,
0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a,
0x15, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x5f, 0x72,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x13, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x51, 0x0a,
0x16, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x5f, 0x72,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x14, 0x66, 0x75, 0x6e, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x23, 0x0a, 0x0c, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x74, 0x65, 0x78, 0x74, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x0d, 0x6b, 0x69, 0x63, 0x6b, 0x5f, 0x72, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x4b, 0x69, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00,
0x52, 0x0c, 0x6b, 0x69, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18,
0x0a, 0x06, 0x73, 0x75, 0x63, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00,
0x52, 0x06, 0x73, 0x75, 0x63, 0x65, 0x73, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c,
0x6f, 0x61, 0x64, 0x32, 0x4b, 0x0a, 0x13, 0x42, 0x6f, 0x74, 0x68, 0x57, 0x61, 0x79, 0x53, 0x74,
0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x04, 0x43, 0x61,
0x6c, 0x6c, 0x12, 0x13, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x13, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65,
0x6e, 0x65, 0x72, 0x69, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x28, 0x01, 0x30, 0x01,
0x42, 0x0d, 0x5a, 0x0b, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_manifest_proto_rpc_proto_rawDescOnce sync.Once
file_manifest_proto_rpc_proto_rawDescData = file_manifest_proto_rpc_proto_rawDesc
)
func file_manifest_proto_rpc_proto_rawDescGZIP() []byte {
file_manifest_proto_rpc_proto_rawDescOnce.Do(func() {
file_manifest_proto_rpc_proto_rawDescData = protoimpl.X.CompressGZIP(file_manifest_proto_rpc_proto_rawDescData)
})
return file_manifest_proto_rpc_proto_rawDescData
}
var file_manifest_proto_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_manifest_proto_rpc_proto_goTypes = []any{
(*RegisterUser)(nil), // 0: api.RegisterUser
(*KickRequest)(nil), // 1: api.KickRequest
(*FunctionDescriptor)(nil), // 2: api.FunctionDescriptor
(*RegisterResponse)(nil), // 3: api.RegisterResponse
(*FunctionCallRequest)(nil), // 4: api.FunctionCallRequest
(*FunctionCallResponse)(nil), // 5: api.FunctionCallResponse
(*GenericMessage)(nil), // 6: api.GenericMessage
}
var file_manifest_proto_rpc_proto_depIdxs = []int32{
0, // 0: api.GenericMessage.register_request:type_name -> api.RegisterUser
3, // 1: api.GenericMessage.register_response:type_name -> api.RegisterResponse
4, // 2: api.GenericMessage.function_call_request:type_name -> api.FunctionCallRequest
5, // 3: api.GenericMessage.function_call_response:type_name -> api.FunctionCallResponse
1, // 4: api.GenericMessage.kick_response:type_name -> api.KickRequest
6, // 5: api.BothWayStreamServer.Call:input_type -> api.GenericMessage
6, // 6: api.BothWayStreamServer.Call:output_type -> api.GenericMessage
6, // [6:7] is the sub-list for method output_type
5, // [5:6] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_manifest_proto_rpc_proto_init() }
func file_manifest_proto_rpc_proto_init() {
if File_manifest_proto_rpc_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_manifest_proto_rpc_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*RegisterUser); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_rpc_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*KickRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_rpc_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*FunctionDescriptor); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_rpc_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*RegisterResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_rpc_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*FunctionCallRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_rpc_proto_msgTypes[5].Exporter = func(v any, i int) any {
switch v := v.(*FunctionCallResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_manifest_proto_rpc_proto_msgTypes[6].Exporter = func(v any, i int) any {
switch v := v.(*GenericMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_manifest_proto_rpc_proto_msgTypes[6].OneofWrappers = []any{
(*GenericMessage_RegisterRequest)(nil),
(*GenericMessage_RegisterResponse)(nil),
(*GenericMessage_FunctionCallRequest)(nil),
(*GenericMessage_FunctionCallResponse)(nil),
(*GenericMessage_TextMessage)(nil),
(*GenericMessage_KickResponse)(nil),
(*GenericMessage_Sucess)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_manifest_proto_rpc_proto_rawDesc,
NumEnums: 0,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_manifest_proto_rpc_proto_goTypes,
DependencyIndexes: file_manifest_proto_rpc_proto_depIdxs,
MessageInfos: file_manifest_proto_rpc_proto_msgTypes,
}.Build()
File_manifest_proto_rpc_proto = out.File
file_manifest_proto_rpc_proto_rawDesc = nil
file_manifest_proto_rpc_proto_goTypes = nil
file_manifest_proto_rpc_proto_depIdxs = nil
}

View File

@@ -1,143 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.20.0--rc1
// source: manifest/proto/rpc.proto
package api
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
BothWayStreamServer_Call_FullMethodName = "/api.BothWayStreamServer/Call"
)
// BothWayStreamServerClient is the client API for BothWayStreamServer service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type BothWayStreamServerClient interface {
// 双向流连接 - 用于注册和函数调用
Call(ctx context.Context, opts ...grpc.CallOption) (BothWayStreamServer_CallClient, error)
}
type bothWayStreamServerClient struct {
cc grpc.ClientConnInterface
}
func NewBothWayStreamServerClient(cc grpc.ClientConnInterface) BothWayStreamServerClient {
return &bothWayStreamServerClient{cc}
}
func (c *bothWayStreamServerClient) Call(ctx context.Context, opts ...grpc.CallOption) (BothWayStreamServer_CallClient, error) {
stream, err := c.cc.NewStream(ctx, &BothWayStreamServer_ServiceDesc.Streams[0], BothWayStreamServer_Call_FullMethodName, opts...)
if err != nil {
return nil, err
}
x := &bothWayStreamServerCallClient{stream}
return x, nil
}
type BothWayStreamServer_CallClient interface {
Send(*GenericMessage) error
Recv() (*GenericMessage, error)
grpc.ClientStream
}
type bothWayStreamServerCallClient struct {
grpc.ClientStream
}
func (x *bothWayStreamServerCallClient) Send(m *GenericMessage) error {
return x.ClientStream.SendMsg(m)
}
func (x *bothWayStreamServerCallClient) Recv() (*GenericMessage, error) {
m := new(GenericMessage)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// BothWayStreamServerServer is the server API for BothWayStreamServer service.
// All implementations must embed UnimplementedBothWayStreamServerServer
// for forward compatibility
type BothWayStreamServerServer interface {
// 双向流连接 - 用于注册和函数调用
Call(BothWayStreamServer_CallServer) error
mustEmbedUnimplementedBothWayStreamServerServer()
}
// UnimplementedBothWayStreamServerServer must be embedded to have forward compatible implementations.
type UnimplementedBothWayStreamServerServer struct {
}
func (UnimplementedBothWayStreamServerServer) Call(BothWayStreamServer_CallServer) error {
return status.Errorf(codes.Unimplemented, "method Call not implemented")
}
func (UnimplementedBothWayStreamServerServer) mustEmbedUnimplementedBothWayStreamServerServer() {}
// UnsafeBothWayStreamServerServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to BothWayStreamServerServer will
// result in compilation errors.
type UnsafeBothWayStreamServerServer interface {
mustEmbedUnimplementedBothWayStreamServerServer()
}
func RegisterBothWayStreamServerServer(s grpc.ServiceRegistrar, srv BothWayStreamServerServer) {
s.RegisterService(&BothWayStreamServer_ServiceDesc, srv)
}
func _BothWayStreamServer_Call_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(BothWayStreamServerServer).Call(&bothWayStreamServerCallServer{stream})
}
type BothWayStreamServer_CallServer interface {
Send(*GenericMessage) error
Recv() (*GenericMessage, error)
grpc.ServerStream
}
type bothWayStreamServerCallServer struct {
grpc.ServerStream
}
func (x *bothWayStreamServerCallServer) Send(m *GenericMessage) error {
return x.ServerStream.SendMsg(m)
}
func (x *bothWayStreamServerCallServer) Recv() (*GenericMessage, error) {
m := new(GenericMessage)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// BothWayStreamServer_ServiceDesc is the grpc.ServiceDesc for BothWayStreamServer service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var BothWayStreamServer_ServiceDesc = grpc.ServiceDesc{
ServiceName: "api.BothWayStreamServer",
HandlerType: (*BothWayStreamServerServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "Call",
Handler: _BothWayStreamServer_Call_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "manifest/proto/rpc.proto",
}

View File

@@ -50,7 +50,7 @@ func init() {
CacheManager.SetAdapter(gcache.NewAdapterRedis(redis))
IsRedisMode = true
}
g.Log().Debug(ctx, "当前运行模式", RunMode)
//g.Log().Debug(ctx, "当前运行模式", RunMode)
g.Log().Debug(ctx, "当前实例ID:", ProcessFlag)
g.Log().Debug(ctx, "是否缓存模式:", IsRedisMode)
g.Log().Debug(ctx, "module cool init finished ...")

View File

@@ -38,3 +38,8 @@ func NewPlayer(opts ...PlayerOption) *Player {
func (p *Player) GetUserID() uint32 {
return p.UserID
}
func (p *Player) SendPack(b []byte) error {
_, err := p.MainConn.Write(b)
return err
}

133
common/rpc/rpc.go Normal file
View File

@@ -0,0 +1,133 @@
package rpc
import (
"context"
"fmt"
"log"
"net/http"
"github.com/filecoin-project/go-jsonrpc"
)
const rpcaddr = "127.0.0.1:40000"
var clientmap = make(map[int]*ClientHandler) //客户端map
var usermap = make(map[int]int) //用户->客户端的map
// Define the client handler interface
type ClientHandler struct {
KickPerson func(int) error //踢人,这里是返回具体的logic
}
// Define the server handler
type ServerHandler struct{}
// 实现踢人
func (h *ServerHandler) Kick(ctx context.Context, userid int) error {
useid1, ok := usermap[userid]
if !ok {
return fmt.Errorf("user not found")
}
return clientmap[useid1].KickPerson(userid) //实现指定服务器踢人
// for _, v := range clientmap {
// err := v.KickPerson(userid)
// if err != nil {
// return fmt.Errorf("call on client: %w", err)
// }
// }
//return nil
}
// 退出指定服务器
func (h *ServerHandler) Quit(ctx context.Context, userid int) error {
return nil
}
// 注册logic服务器
func (h *ServerHandler) RegisterLogic(ctx context.Context, port int) error {
revClient, ok := jsonrpc.ExtractReverseClient[ClientHandler](ctx)
if !ok {
return fmt.Errorf("no reverse client")
}
clientmap[port] = &revClient
return nil
}
// 用户登录事件
func (h *ServerHandler) UserLogin(ctx context.Context, port int, userid int) error {
usermap[userid] = port
return nil
}
// 用户登出事件
func (h *ServerHandler) UserLogout(ctx context.Context, port int, userid int) error {
delete(usermap, userid)
return nil
}
func StartServer() {
// create a new server instance
rpcServer := jsonrpc.NewServer(jsonrpc.WithReverseClient[ClientHandler](""))
rpcServer.Register("", &ServerHandler{})
// go time.AfterFunc(3000, func() {
// testjsonrpc()
// })
err := http.ListenAndServe(rpcaddr, rpcServer)
fmt.Println(err)
}
var closer jsonrpc.ClientCloser
func StartClient(port uint16, callback any) *struct {
Kick func(int32) error
Quit func(int32) error
RegisterLogic func(int32) error
UserLogin func(int32, int32) error
UserLogout func(int32, int32) error
} {
closer1, err := jsonrpc.NewMergeClient(context.Background(), "ws://"+rpcaddr, "", []interface{}{
&RPCClient,
}, nil, jsonrpc.WithClientHandler("", callback))
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
if port != 0 { //注册logic
RPCClient.RegisterLogic(int32(port))
}
closer = closer1
return &RPCClient
}
// 关闭客户端
func CloseClient() {
if closer != nil {
closer()
}
}
// Setup RPCClient with reverse call handler
var RPCClient struct {
Kick func(int32) error //踢人
Quit func(int32) error //退出指定服务器
RegisterLogic func(int32) error //注册服务器消息
UserLogin func(int32, int32) error //用户登录事件
UserLogout func(int32, int32) error //用户登出事件
}

View File

@@ -0,0 +1,50 @@
package errorcode
import "github.com/tnnmigga/enum"
// ErrorCode 错误码枚举类型
type ErrorCode uint32
// ErrorMap 错误码到错误信息的映射
//var ErrorMap = make(map[ErrorCode]ErrorInfo)
// ErrorCodes 错误码注册表
var ErrorCodes = enum.New[struct {
// 系统错误码
ErrLoginFailed ErrorCode `enum:"10001"` // 登录失败
ErrAlreadyLoggedIn ErrorCode `enum:"10004"` // 已在别处登录
ErrIllegalLanguage ErrorCode `enum:"10005"` // 使用非法语言
ErrUserOffline ErrorCode `enum:"10006"` // 用户离线
ErrSystemBusy ErrorCode `enum:"10003"` // 系统繁忙
ErrInvalidPassword ErrorCode `enum:"10002"` // 密码错误
ErrXinDouLimit ErrorCode `enum:"103106"` // XIN豆上限
ErrNoFollowedPet ErrorCode `enum:"19001"` // 无跟随精灵
ErrWrongElementType ErrorCode `enum:"19002"` // 元素类型错误
ErrPositionOccupied ErrorCode `enum:"10101"` // 位置已被占用
ErrXinPlanSleeping ErrorCode `enum:"10009"` // XIN计划休眠
ErrNoEnergy ErrorCode `enum:"10010"` // 能量不足
// 战斗相关错误码
ErrFightCanceled ErrorCode `enum:"11001"` // 战斗取消
ErrFightFinished ErrorCode `enum:"11002"` // 战斗已结束
ErrAlreadyActed ErrorCode `enum:"11012"` // 本回合已操作
ErrCannotCancelFight ErrorCode `enum:"11005"` // 不能取消对战
ErrNoEnergyForFight ErrorCode `enum:"11013"` // 精灵无体力
ErrDifferentScene ErrorCode `enum:"11008"` // 不在同一场景
ErrNoBossInScene ErrorCode `enum:"11009"` // 场景中无Boss
ErrNoQualifiedPet ErrorCode `enum:"11030"` // 无符合条件的精灵
ErrExceedFightHours ErrorCode `enum:"11010"` // 在线时间过长
// 精灵相关错误码
ErrNoRequiredPets ErrorCode `enum:"13001"` // 缺少必要精灵
ErrAlreadyExchanged ErrorCode `enum:"13002"` // 已兑换过精灵
ErrCannotEvolve ErrorCode `enum:"13009"` // 精灵不能进化
ErrLevelTooLow ErrorCode `enum:"13007"` // 等级不足
ErrCannotDisplayPet ErrorCode `enum:"13017"` // 不能展示精灵
ErrAlreadyEaten ErrorCode `enum:"17018"` // 今天已被吃掉
ErrItemInUse ErrorCode `enum:"13023"` // 道具正在使用
ErrPetNotExist ErrorCode `enum:"103011"` // 精灵不存在
ErrCannotRevive ErrorCode `enum:"13033"` // 不能还原元神
// 其他错误码...
}]()

View File

@@ -18,6 +18,16 @@ type TomeeHeader struct {
Result uint32 `json:"result"`
Data []byte `json:"data"|struc:"skip"` //组包忽略此字段// struc:"[0]pad"
}
func NewTomeeHeader() *TomeeHeader {
return &TomeeHeader{
// Len: 0,
Version: "7",
}
}
type TomeeHandler struct {
Callback func(conn gnet.Conn, data TomeeHeader)
}

View File

@@ -20,11 +20,25 @@ import (
"github.com/panjf2000/gnet/v2"
)
var maincontroller = NewController() //注入service
var Maincontroller = NewController() //注入service
// 分发cmd逻辑实现Controller
type Controller struct {
Port uint32
RPCClient struct {
Kick func(int32) error
Quit func(int32) error
RegisterLogic func(int32) error
UserLogin func(int32, int32) error
UserLogout func(int32, int32) error
}
}
func (h *Controller) KickPerson(a int) error {
//TODO 这里待实现踢人
fmt.Println("检测到踢人请求", a)
service.KickPlayer(uint32(a))
return nil
}
func NewController() *Controller {
return &Controller{}
}
@@ -42,7 +56,7 @@ func init() { //默认初始化扫描
// 解析命令行参数
cool.Config.PortBL = gcmd.GetOpt("port", "1").Uint32()
// 获取对象的反射值和类型
value := reflect.ValueOf(maincontroller)
value := reflect.ValueOf(Maincontroller)
// 获取类型
typ := value.Type()
@@ -59,6 +73,9 @@ func init() { //默认初始化扫描
var func_cmd cmd.EnumCommandID
func_cmd = getcmd(methodValue.Type().In(0))
if func_cmd == 0 { //说明不是注册方法
continue
}
if !cmd.Isexist(cmd.CommandID, cmd.EnumCommandID(func_cmd)) {
fmt.Println("ID方法存在cmd未注册", func_cmd)

View File

@@ -11,13 +11,14 @@ import (
)
// 处理命令: 1001
func (h Controller) Login(data login.LoginSidInfo, c gnet.Conn) []byte { //这个时候player应该是空的
func (h *Controller) Login(data login.LoginSidInfo, c gnet.Conn) []byte { //这个时候player应该是空的
//fmt.Println(data.CheakSession()) //检查结构体
if tt := data.CheakSession(); tt { //说明sid正确
h.RPCClient.Kick(int32(data.Head.UserID)) //先踢人
service.SetPlayer(c, data.Head.UserID)
h.RPCClient.UserLogin(int32(h.Port), int32(data.Head.UserID)) //初始化用户登录
}
t1, _ := hex.DecodeString("0000045D37000003E9000186A600000000000186A6683F89CF6E69656F0000000000000000000000000008000F00000000000000000000000000000000000000000000000000000001000001DB0000018B000000000000A8C000000000000000000000000000000000000000080001388000000001000000017FFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000064000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001FFFFFFFF000000004E4F4E4F0000000000000000000000000000000000000001000000010000000100000001000000010000000100000001000000000003030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030000000100000064000000000000000000000000000000000000001F000000000000006400000000000093F4000093F4000000D5000000F7000000AD00000088000000920000008C0000009C00000000000000000000000000000000000000000000000000000004000027900000001B00004E6200000014000028380000002800004E3E0000002368493DC60000000000000000000000000000000000000000000100000000000000A937000007D1000186A600000000000186A66E69656F00000000000000000000000000000000000000000000000F0000000000000000000001DB0000018B0000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFF0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000")

View File

@@ -1,123 +0,0 @@
package main
import (
"blazing/common/api"
"context"
"fmt"
"io"
"log"
"net"
"time"
"google.golang.org/grpc"
)
const rpcaddr = "127.0.0.1:9999"
// Server
type Server struct {
api.UnimplementedBothWayStreamServerServer
}
// DemoMethod 实现 proto 的方法
func (s *Server) Call(server api.BothWayStreamServer_CallServer) error {
var count int
// 启一个携程监听读事件
go func() {
for {
p, err := server.Recv()
if err != nil && err == io.EOF {
return
}
if err != nil {
fmt.Println("服务端接收错误", err)
break
}
fmt.Println("服务端接收数据", p.GetKickResponse().UserId)
}
}()
// 持续写事件
for {
count++
err := server.Send(&api.GenericMessage{
Payload: &api.GenericMessage_KickResponse{
KickResponse: &api.KickRequest{
UserId: int32(count),
},
},
})
if err != nil {
break
}
time.Sleep(time.Second)
}
return nil
}
func rpcserver() {
// 实例化一个 grpc 服务
g := grpc.NewServer()
s := new(Server)
// 绑定
api.RegisterBothWayStreamServerServer(g, s)
// grpc 监听在 8888 端口
l, err := net.Listen("tcp", rpcaddr)
if err != nil {
log.Fatal(err)
}
// 服务启动
err = g.Serve(l)
if err != nil {
panic(err)
}
}
func rpcclient() {
connect, err := grpc.Dial(rpcaddr, grpc.WithInsecure())
if err != nil {
panic(err)
}
defer connect.Close()
client := api.NewBothWayStreamServerClient(connect)
stream, err := client.Call(context.Background())
if err != nil {
panic(err)
}
// 接收数据
go func() {
for {
reply, err := stream.Recv()
if err != nil {
break
}
fmt.Println("客户端接收到的数据是:", reply.Payload)
}
}()
// 发送数据
var count int
for {
count++
err := stream.Send(&api.GenericMessage{
Payload: &api.GenericMessage_KickResponse{
KickResponse: &api.KickRequest{
UserId: int32(count),
},
},
})
if err != nil {
log.Printf("发送失败: %v", err)
break
}
time.Sleep(time.Second)
// // 10 次后发送关闭
// if count == 10 {
// err := stream.CloseSend()
// if err != nil {
// break
// }
// }
}
}

View File

@@ -1,11 +1,13 @@
package main
import (
"blazing/common/rpc"
"blazing/common/socket"
"blazing/common/socket/handler"
"blazing/cool"
"blazing/logic/controller"
"blazing/modules/blazing/service"
"fmt"
"log"
"math/rand"
@@ -68,13 +70,21 @@ func Start(serverid uint32) {
if err != nil {
log.Fatalf("Failed to determine port: %v", err)
}
//go rpcclient()
//ants.Submit(rpcclient)
//随机端口产生,然后给sql注册端口
go func() {
t := rpc.StartClient(uint16(serverid), controller.Maincontroller)
controller.Maincontroller.RPCClient = *t //将RPC赋值Start
controller.Maincontroller.Port = serverid //赋值服务器ID
}()
//go rpc.StartClient(uint16(serverid), &controller.Maincontroller)
service.NewLoginServiceService().SetServerID(serverid, gconv.Uint16(port))
socket.NewServer(socket.WithCORS(), socket.WithPort(port), socket.WithSocketHandler(head)).Start()
} else {
go rpc.StartServer()
//go rpcserver() //对login tcp启动
//ants.Submit(rpcserver)
socket.NewServer(socket.WithCORS(), socket.WithPort(defaultPort), socket.WithSocketHandler(head)).Start()

View File

@@ -3,6 +3,8 @@ package service
import (
"blazing/common/core"
"blazing/common/data/entity"
"blazing/common/socket/errorcode"
"blazing/common/socket/handler"
"github.com/panjf2000/gnet/v2"
)
@@ -24,7 +26,24 @@ func GetPlayer(c gnet.Conn, userid uint32) *entity.Player { //TODO 这里待优
return player
// return nil
}
func KickPlayer(userid uint32) { //踢出玩家
//TODO 返回错误码
//var player *entity.Player
if player1, ok := core.Mainplayer.Load((userid)); ok {
player := player1.(*entity.Player) //取成功,否则创建
head := handler.NewTomeeHeader()
head.Result = uint32(errorcode.ErrorCodes.ErrAlreadyLoggedIn)
head.UserID = userid
head.CMD = 1001
player.SendPack(core.Pack(*head, nil))
player.MainConn.Close()
// clientdata.Player = player
}
//return player
// return nil
}
func SetPlayer(c gnet.Conn, userid uint32) *entity.Player { //TODO 这里待优化,可能存在内存泄漏问题
clientdata := c.Context().(*entity.ClientData)
player := entity.NewPlayer(

View File

@@ -1,8 +1,11 @@
package main
import (
"fmt"
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
"blazing/common/rpc"
_ "blazing/contrib/drivers/pgsql"
_ "blazing/contrib/files/local"
@@ -25,7 +28,19 @@ import (
)
func main() {
// go Start(cool.Config.Port)
//go rpc()
cmd.Main.Run(gctx.New())
}
func kick(id int) {
// go Start(cool.Config.Port)
//go rpc()
go func() {
t := rpc.StartClient(0, &struct{}{})
err := t.Kick(1)
fmt.Println(err)
//err := t.Kick(1)
err = t.Kick(10001)
fmt.Println(err)
}()
}

View File

@@ -1,71 +0,0 @@
syntax = "proto3";
// 指定 Go 包路径(推荐使用完整的模块路径)
option go_package = "/common/api";
package api;
// 注册请求 - logic 用户登录后注册
message RegisterUser {
int32 identity = 1; // 客户端身份,进入后保存id->端口 实现通知踢人以及进程退出
int32 user_id = 2; // 执行踢人操作的用户id
}
// 注册请求 - B客户端使用此消息向服务器注册
message KickRequest {
int32 user_id = 1; // 执行踢人操作的用户id
}
// 函数描述符
message FunctionDescriptor {
string function_name = 1; // 函数名称
string input_type = 2; // 输入参数类型
string output_type = 3; // 输出参数类型
string description = 4; // 函数描述
}
// 注册响应
message RegisterResponse {
bool success = 1; // 注册是否成功
string message = 2; // 消息描述
string registration_id = 3; // 注册ID
}
// 函数调用请求 - A客户端使用此消息请求调用B的函数
message FunctionCallRequest {
string target_client_id = 1; // 目标客户端IDB
string function_name = 2; // 要调用的函数名
bytes parameters = 3; // 序列化后的函数参数
string call_id = 4; // 调用ID用于关联响应
}
// 函数调用响应 - 从B客户端返回给A客户端
message FunctionCallResponse {
string call_id = 1; // 对应请求的调用ID
bool success = 2; // 调用是否成功
bytes result = 3; // 序列化后的返回结果
string error_message = 4; // 错误消息(如果失败)
}
// 通用消息
message GenericMessage {
oneof payload {
RegisterUser register_request = 1;
RegisterResponse register_response = 2;
FunctionCallRequest function_call_request = 3;
FunctionCallResponse function_call_response = 4;
string text_message = 5; // 普通文本消息
KickRequest kick_response = 6;
bool sucess = 7;
}
}
// 主服务接口
service BothWayStreamServer {
// 双向流连接 - 用于注册和函数调用
rpc Call (stream GenericMessage) returns (stream GenericMessage);
// 函数调用服务 - A客户端通过此方法请求调用B的函数
//rpc CallFunction (FunctionCallRequest) returns (FunctionCallResponse);
}