diff --git a/bin/protoc-3.19.4-win64/bin/protoc.exe b/bin/protoc-3.19.4-win64/bin/protoc.exe new file mode 100644 index 0000000..c392590 Binary files /dev/null and b/bin/protoc-3.19.4-win64/bin/protoc.exe differ diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/any.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/any.proto similarity index 82% rename from bin/protoc-3.5.1-win32/include/google/protobuf/any.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/any.proto index c748667..6ed8a23 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/any.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/any.proto @@ -33,7 +33,7 @@ syntax = "proto3"; package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/any"; +option go_package = "google.golang.org/protobuf/types/known/anypb"; option java_package = "com.google.protobuf"; option java_outer_classname = "AnyProto"; option java_multiple_files = true; @@ -77,10 +77,13 @@ option objc_class_prefix = "GPB"; // Example 4: Pack and unpack a message in Go // // foo := &pb.Foo{...} -// any, err := ptypes.MarshalAny(foo) +// any, err := anypb.New(foo) +// if err != nil { +// ... +// } // ... // foo := &pb.Foo{} -// if err := ptypes.UnmarshalAny(any, foo); err != nil { +// if err := any.UnmarshalTo(foo); err != nil { // ... // } // @@ -120,17 +123,19 @@ option objc_class_prefix = "GPB"; // } // message Any { - // A URL/resource name whose content describes the type of the - // serialized protocol buffer message. + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. This string must contain at least + // one "/" character. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). // - // For URLs which use the scheme `http`, `https`, or no scheme, the - // following restrictions and interpretations apply: + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: // // * If no scheme is provided, `https` is assumed. - // * The last segment of the URL's path must represent the fully - // qualified name of the type (as in `path/google.protobuf.Duration`). - // The name should be in a canonical form (e.g., leading "." is - // not accepted). // * An HTTP GET on the URL must yield a [google.protobuf.Type][] // value in binary format, or produce an error. // * Applications are allowed to cache lookup results based on the @@ -139,6 +144,10 @@ message Any { // on changes to types. (Use versioned type names to manage // breaking changes.) // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. + // // Schemes other than `http`, `https` (or the empty scheme) might be // used with implementation specific semantics. // diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/api.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/api.proto similarity index 98% rename from bin/protoc-3.5.1-win32/include/google/protobuf/api.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/api.proto index f37ee2f..3d598fc 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/api.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/api.proto @@ -40,7 +40,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "ApiProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/api;api"; +option go_package = "google.golang.org/protobuf/types/known/apipb"; // Api is a light-weight descriptor for an API Interface. // @@ -52,7 +52,6 @@ option go_package = "google.golang.org/genproto/protobuf/api;api"; // this message itself. See https://cloud.google.com/apis/design/glossary for // detailed terminology. message Api { - // The fully qualified name of this interface, including package name // followed by the interface's simple name. string name = 1; @@ -99,7 +98,6 @@ message Api { // Method represents a method of an API interface. message Method { - // The simple name of this method. string name = 1; @@ -169,7 +167,7 @@ message Method { // The mixin construct implies that all methods in `AccessControl` are // also declared with same name and request/response types in // `Storage`. A documentation generator or annotation processor will -// see the effective `Storage.GetAcl` method after inherting +// see the effective `Storage.GetAcl` method after inheriting // documentation and annotations as follows: // // service Storage { diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/compiler/plugin.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/compiler/plugin.proto similarity index 92% rename from bin/protoc-3.5.1-win32/include/google/protobuf/compiler/plugin.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/compiler/plugin.proto index 5b55745..9242aac 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/compiler/plugin.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/compiler/plugin.proto @@ -45,11 +45,12 @@ // flag "--${NAME}_out" is passed to protoc. syntax = "proto2"; + package google.protobuf.compiler; option java_package = "com.google.protobuf.compiler"; option java_outer_classname = "PluginProtos"; -option go_package = "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go"; +option go_package = "google.golang.org/protobuf/types/pluginpb"; import "google/protobuf/descriptor.proto"; @@ -106,6 +107,16 @@ message CodeGeneratorResponse { // exiting with a non-zero status code. optional string error = 1; + // A bitmask of supported features that the code generator supports. + // This is a bitwise "or" of values from the Feature enum. + optional uint64 supported_features = 2; + + // Sync with code_generator.h. + enum Feature { + FEATURE_NONE = 0; + FEATURE_PROTO3_OPTIONAL = 1; + } + // Represents a single generated file. message File { // The file name, relative to the output directory. The name must not @@ -162,6 +173,11 @@ message CodeGeneratorResponse { // The file contents. optional string content = 15; + + // Information describing the file content being inserted. If an insertion + // point is used, this information will be appropriately offset and inserted + // into the code generation metadata for the generated files. + optional GeneratedCodeInfo generated_code_info = 16; } repeated File file = 15; } diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/descriptor.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/descriptor.proto similarity index 86% rename from bin/protoc-3.5.1-win32/include/google/protobuf/descriptor.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/descriptor.proto index 8697a50..156e410 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/descriptor.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/descriptor.proto @@ -40,7 +40,8 @@ syntax = "proto2"; package google.protobuf; -option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor"; + +option go_package = "google.golang.org/protobuf/types/descriptorpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; option csharp_namespace = "Google.Protobuf.Reflection"; @@ -59,8 +60,8 @@ message FileDescriptorSet { // Describes a complete .proto file. message FileDescriptorProto { - optional string name = 1; // file name, relative to root of source tree - optional string package = 2; // e.g. "foo", "foo.bar", etc. + optional string name = 1; // file name, relative to root of source tree + optional string package = 2; // e.g. "foo", "foo.bar", etc. // Names of files imported by this file. repeated string dependency = 3; @@ -100,8 +101,8 @@ message DescriptorProto { repeated EnumDescriptorProto enum_type = 4; message ExtensionRange { - optional int32 start = 1; - optional int32 end = 2; + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Exclusive. optional ExtensionRangeOptions options = 3; } @@ -115,8 +116,8 @@ message DescriptorProto { // fields or extension ranges in the same message. Reserved ranges may // not overlap. message ReservedRange { - optional int32 start = 1; // Inclusive. - optional int32 end = 2; // Exclusive. + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Exclusive. } repeated ReservedRange reserved_range = 9; // Reserved field names, which may not be used by fields in the same message. @@ -128,6 +129,7 @@ message ExtensionRangeOptions { // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; + // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; } @@ -137,42 +139,42 @@ message FieldDescriptorProto { enum Type { // 0 is reserved for errors. // Order is weird for historical reasons. - TYPE_DOUBLE = 1; - TYPE_FLOAT = 2; + TYPE_DOUBLE = 1; + TYPE_FLOAT = 2; // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if // negative values are likely. - TYPE_INT64 = 3; - TYPE_UINT64 = 4; + TYPE_INT64 = 3; + TYPE_UINT64 = 4; // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if // negative values are likely. - TYPE_INT32 = 5; - TYPE_FIXED64 = 6; - TYPE_FIXED32 = 7; - TYPE_BOOL = 8; - TYPE_STRING = 9; + TYPE_INT32 = 5; + TYPE_FIXED64 = 6; + TYPE_FIXED32 = 7; + TYPE_BOOL = 8; + TYPE_STRING = 9; // Tag-delimited aggregate. // Group type is deprecated and not supported in proto3. However, Proto3 // implementations should still be able to parse the group wire format and // treat group fields as unknown fields. - TYPE_GROUP = 10; - TYPE_MESSAGE = 11; // Length-delimited aggregate. + TYPE_GROUP = 10; + TYPE_MESSAGE = 11; // Length-delimited aggregate. // New in version 2. - TYPE_BYTES = 12; - TYPE_UINT32 = 13; - TYPE_ENUM = 14; - TYPE_SFIXED32 = 15; - TYPE_SFIXED64 = 16; - TYPE_SINT32 = 17; // Uses ZigZag encoding. - TYPE_SINT64 = 18; // Uses ZigZag encoding. - }; + TYPE_BYTES = 12; + TYPE_UINT32 = 13; + TYPE_ENUM = 14; + TYPE_SFIXED32 = 15; + TYPE_SFIXED64 = 16; + TYPE_SINT32 = 17; // Uses ZigZag encoding. + TYPE_SINT64 = 18; // Uses ZigZag encoding. + } enum Label { // 0 is reserved for errors - LABEL_OPTIONAL = 1; - LABEL_REQUIRED = 2; - LABEL_REPEATED = 3; - }; + LABEL_OPTIONAL = 1; + LABEL_REQUIRED = 2; + LABEL_REPEATED = 3; + } optional string name = 1; optional int32 number = 3; @@ -211,6 +213,29 @@ message FieldDescriptorProto { optional string json_name = 10; optional FieldOptions options = 8; + + // If true, this is a proto3 "optional". When a proto3 field is optional, it + // tracks presence regardless of field type. + // + // When proto3_optional is true, this field must be belong to a oneof to + // signal to old proto3 clients that presence is tracked for this field. This + // oneof is known as a "synthetic" oneof, and this field must be its sole + // member (each proto3 optional field gets its own synthetic oneof). Synthetic + // oneofs exist in the descriptor only, and do not generate any API. Synthetic + // oneofs must be ordered after all "real" oneofs. + // + // For message fields, proto3_optional doesn't create any semantic change, + // since non-repeated message fields always track presence. However it still + // indicates the semantic detail of whether the user wrote "optional" or not. + // This can be useful for round-tripping the .proto file. For consistency we + // give message fields a synthetic oneof also, even though it is not required + // to track presence. This is especially important because the parser can't + // tell if a field is a message or an enum, so it must always create a + // synthetic oneof. + // + // Proto2 optional fields do not set this flag, because they already indicate + // optional with `LABEL_OPTIONAL`. + optional bool proto3_optional = 17; } // Describes a oneof. @@ -234,8 +259,8 @@ message EnumDescriptorProto { // is inclusive such that it can appropriately represent the entire int32 // domain. message EnumReservedRange { - optional int32 start = 1; // Inclusive. - optional int32 end = 2; // Inclusive. + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Inclusive. } // Range of reserved numeric values. Reserved numeric values may not be used @@ -276,9 +301,9 @@ message MethodDescriptorProto { optional MethodOptions options = 4; // Identifies if client streams multiple client messages - optional bool client_streaming = 5 [default=false]; + optional bool client_streaming = 5 [default = false]; // Identifies if server streams multiple server messages - optional bool server_streaming = 6 [default=false]; + optional bool server_streaming = 6 [default = false]; } @@ -314,7 +339,6 @@ message MethodDescriptorProto { // If this turns out to be popular, a web service will be set up // to automatically assign option numbers. - message FileOptions { // Sets the Java package where classes generated from this .proto will be @@ -324,20 +348,20 @@ message FileOptions { optional string java_package = 1; - // If set, all the classes from the .proto file are wrapped in a single - // outer class with the given name. This applies to both Proto1 - // (equivalent to the old "--one_java_file" option) and Proto2 (where - // a .proto always translates to a single class, but you may want to - // explicitly choose the class name). + // Controls the name of the wrapper Java class generated for the .proto file. + // That class will always contain the .proto file's getDescriptor() method as + // well as any top-level extensions defined in the .proto file. + // If java_multiple_files is disabled, then all the other classes from the + // .proto file will be nested inside the single wrapper outer class. optional string java_outer_classname = 8; - // If set true, then the Java code generator will generate a separate .java + // If enabled, then the Java code generator will generate a separate .java // file for each top-level message, enum, and service defined in the .proto - // file. Thus, these types will *not* be nested inside the outer class - // named by java_outer_classname. However, the outer class will still be + // file. Thus, these types will *not* be nested inside the wrapper class + // named by java_outer_classname. However, the wrapper class will still be // generated to contain the file's getDescriptor() method as well as any // top-level extensions defined in the file. - optional bool java_multiple_files = 10 [default=false]; + optional bool java_multiple_files = 10 [default = false]; // This option does nothing. optional bool java_generate_equals_and_hash = 20 [deprecated=true]; @@ -348,17 +372,17 @@ message FileOptions { // Message reflection will do the same. // However, an extension field still accepts non-UTF-8 byte sequences. // This option has no effect on when used with the lite runtime. - optional bool java_string_check_utf8 = 27 [default=false]; + optional bool java_string_check_utf8 = 27 [default = false]; // Generated classes can be optimized for speed or code size. enum OptimizeMode { - SPEED = 1; // Generate complete code for parsing, serialization, - // etc. - CODE_SIZE = 2; // Use ReflectionOps to implement these methods. - LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. + SPEED = 1; // Generate complete code for parsing, serialization, + // etc. + CODE_SIZE = 2; // Use ReflectionOps to implement these methods. + LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. } - optional OptimizeMode optimize_for = 9 [default=SPEED]; + optional OptimizeMode optimize_for = 9 [default = SPEED]; // Sets the Go package where structs generated from this .proto will be // placed. If omitted, the Go package will be derived from the following: @@ -369,6 +393,7 @@ message FileOptions { + // Should generic services be generated in each language? "Generic" services // are not specific to any particular RPC system. They are generated by the // main code generators in each language (without additional plugins). @@ -379,20 +404,20 @@ message FileOptions { // that generate code specific to your particular RPC system. Therefore, // these default to false. Old code which depends on generic services should // explicitly set them to true. - optional bool cc_generic_services = 16 [default=false]; - optional bool java_generic_services = 17 [default=false]; - optional bool py_generic_services = 18 [default=false]; - optional bool php_generic_services = 42 [default=false]; + optional bool cc_generic_services = 16 [default = false]; + optional bool java_generic_services = 17 [default = false]; + optional bool py_generic_services = 18 [default = false]; + optional bool php_generic_services = 42 [default = false]; // Is this file deprecated? // Depending on the target platform, this can emit Deprecated annotations // for everything in the file, or it will be completely ignored; in the very // least, this is a formalization for deprecating files. - optional bool deprecated = 23 [default=false]; + optional bool deprecated = 23 [default = false]; // Enables the use of arenas for the proto messages in this file. This applies // only to generated classes for C++. - optional bool cc_enable_arenas = 31 [default=false]; + optional bool cc_enable_arenas = 31 [default = true]; // Sets the objective c class prefix which is prepended to all objective c @@ -417,6 +442,17 @@ message FileOptions { // determining the namespace. optional string php_namespace = 41; + // Use this option to change the namespace of php generated metadata classes. + // Default is empty. When this option is empty, the proto file name will be + // used for determining the namespace. + optional string php_metadata_namespace = 44; + + // Use this option to change the package of ruby generated classes. Default + // is empty. When this option is not set, the package name will be used for + // determining the ruby package. + optional string ruby_package = 45; + + // The parser stores options it doesn't recognize here. // See the documentation for the "Options" section above. repeated UninterpretedOption uninterpreted_option = 999; @@ -447,18 +483,20 @@ message MessageOptions { // // Because this is an option, the above two restrictions are not enforced by // the protocol compiler. - optional bool message_set_wire_format = 1 [default=false]; + optional bool message_set_wire_format = 1 [default = false]; // Disables the generation of the standard "descriptor()" accessor, which can // conflict with a field of the same name. This is meant to make migration // from proto1 easier; new code should avoid fields named "descriptor". - optional bool no_standard_descriptor_accessor = 2 [default=false]; + optional bool no_standard_descriptor_accessor = 2 [default = false]; // Is this message deprecated? // Depending on the target platform, this can emit Deprecated annotations // for the message, or it will be completely ignored; in the very least, // this is a formalization for deprecating messages. - optional bool deprecated = 3 [default=false]; + optional bool deprecated = 3 [default = false]; + + reserved 4, 5, 6; // Whether the message is an automatically generated map entry type for the // maps field. @@ -475,7 +513,7 @@ message MessageOptions { // // Implementations may choose not to generate the map_entry=true message, but // use a native map in the target language to hold the keys and values. - // The reflection APIs in such implementions still need to work as + // The reflection APIs in such implementations still need to work as // if the field is a repeated message field. // // NOTE: Do not set the option in .proto files. Always use the maps syntax @@ -486,6 +524,7 @@ message MessageOptions { reserved 8; // javalite_serializable reserved 9; // javanano_as_lite + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -565,16 +604,16 @@ message FieldOptions { // implementation must either *always* check its required fields, or *never* // check its required fields, regardless of whether or not the message has // been parsed. - optional bool lazy = 5 [default=false]; + optional bool lazy = 5 [default = false]; // Is this field deprecated? // Depending on the target platform, this can emit Deprecated annotations // for accessors, or it will be completely ignored; in the very least, this // is a formalization for deprecating fields. - optional bool deprecated = 3 [default=false]; + optional bool deprecated = 3 [default = false]; // For Google-internal migration only. Do not use. - optional bool weak = 10 [default=false]; + optional bool weak = 10 [default = false]; // The parser stores options it doesn't recognize here. See above. @@ -604,7 +643,7 @@ message EnumOptions { // Depending on the target platform, this can emit Deprecated annotations // for the enum, or it will be completely ignored; in the very least, this // is a formalization for deprecating enums. - optional bool deprecated = 3 [default=false]; + optional bool deprecated = 3 [default = false]; reserved 5; // javanano_as_lite @@ -620,7 +659,7 @@ message EnumValueOptions { // Depending on the target platform, this can emit Deprecated annotations // for the enum value, or it will be completely ignored; in the very least, // this is a formalization for deprecating enum values. - optional bool deprecated = 1 [default=false]; + optional bool deprecated = 1 [default = false]; // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -640,7 +679,7 @@ message ServiceOptions { // Depending on the target platform, this can emit Deprecated annotations // for the service, or it will be completely ignored; in the very least, // this is a formalization for deprecating services. - optional bool deprecated = 33 [default=false]; + optional bool deprecated = 33 [default = false]; // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -660,18 +699,18 @@ message MethodOptions { // Depending on the target platform, this can emit Deprecated annotations // for the method, or it will be completely ignored; in the very least, // this is a formalization for deprecating methods. - optional bool deprecated = 33 [default=false]; + optional bool deprecated = 33 [default = false]; // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, // or neither? HTTP based RPC implementation may choose GET verb for safe // methods, and PUT verb for idempotent methods instead of the default POST. enum IdempotencyLevel { IDEMPOTENCY_UNKNOWN = 0; - NO_SIDE_EFFECTS = 1; // implies idempotent - IDEMPOTENT = 2; // idempotent, but may have side effects + NO_SIDE_EFFECTS = 1; // implies idempotent + IDEMPOTENT = 2; // idempotent, but may have side effects } - optional IdempotencyLevel idempotency_level = - 34 [default=IDEMPOTENCY_UNKNOWN]; + optional IdempotencyLevel idempotency_level = 34 + [default = IDEMPOTENCY_UNKNOWN]; // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -752,7 +791,7 @@ message SourceCodeInfo { // beginning of the "extend" block and is shared by all extensions within // the block. // - Just because a location's span is a subset of some other location's span - // does not mean that it is a descendent. For example, a "group" defines + // does not mean that it is a descendant. For example, a "group" defines // both a type and a field in a single declaration. Thus, the locations // corresponding to the type and field and their components will overlap. // - Code which tries to interpret locations should probably be designed to @@ -783,14 +822,14 @@ message SourceCodeInfo { // [ 4, 3, 2, 7 ] // this path refers to the whole field declaration (from the beginning // of the label to the terminating semicolon). - repeated int32 path = 1 [packed=true]; + repeated int32 path = 1 [packed = true]; // Always has exactly three or four elements: start line, start column, // end line (optional, otherwise assumed same as start line), end column. // These are packed into a single field for efficiency. Note that line // and column numbers are zero-based -- typically you will want to add // 1 to each before displaying to a user. - repeated int32 span = 2 [packed=true]; + repeated int32 span = 2 [packed = true]; // If this SourceCodeInfo represents a complete declaration, these are any // comments appearing before and after the declaration which appear to be @@ -855,7 +894,7 @@ message GeneratedCodeInfo { message Annotation { // Identifies the element in the original source .proto file. This field // is formatted the same as SourceCodeInfo.Location.path. - repeated int32 path = 1 [packed=true]; + repeated int32 path = 1 [packed = true]; // Identifies the filesystem path to the original source .proto. optional string source_file = 2; diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/duration.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/duration.proto similarity index 97% rename from bin/protoc-3.5.1-win32/include/google/protobuf/duration.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/duration.proto index 975fce4..81c3e36 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/duration.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/duration.proto @@ -34,7 +34,7 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/duration"; +option go_package = "google.golang.org/protobuf/types/known/durationpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "DurationProto"; option java_multiple_files = true; @@ -61,7 +61,7 @@ option objc_class_prefix = "GPB"; // if (duration.seconds < 0 && duration.nanos > 0) { // duration.seconds += 1; // duration.nanos -= 1000000000; -// } else if (durations.seconds > 0 && duration.nanos < 0) { +// } else if (duration.seconds > 0 && duration.nanos < 0) { // duration.seconds -= 1; // duration.nanos += 1000000000; // } @@ -101,7 +101,6 @@ option objc_class_prefix = "GPB"; // // message Duration { - // Signed seconds of the span of time. Must be from -315,576,000,000 // to +315,576,000,000 inclusive. Note: these bounds are computed from: // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/empty.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/empty.proto similarity index 97% rename from bin/protoc-3.5.1-win32/include/google/protobuf/empty.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/empty.proto index 03cacd2..5f992de 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/empty.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/empty.proto @@ -33,7 +33,7 @@ syntax = "proto3"; package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/empty"; +option go_package = "google.golang.org/protobuf/types/known/emptypb"; option java_package = "com.google.protobuf"; option java_outer_classname = "EmptyProto"; option java_multiple_files = true; diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/field_mask.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/field_mask.proto similarity index 88% rename from bin/protoc-3.5.1-win32/include/google/protobuf/field_mask.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/field_mask.proto index eb96ba0..6b5104f 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/field_mask.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/field_mask.proto @@ -37,7 +37,8 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "FieldMaskProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; +option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb"; +option cc_enable_arenas = true; // `FieldMask` represents a set of symbolic field paths, for example: // @@ -107,57 +108,49 @@ option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; // describe the updated values, the API ignores the values of all // fields not covered by the mask. // -// If a repeated field is specified for an update operation, the existing -// repeated values in the target resource will be overwritten by the new values. -// Note that a repeated field is only allowed in the last position of a `paths` -// string. +// If a repeated field is specified for an update operation, new values will +// be appended to the existing repeated field in the target resource. Note that +// a repeated field is only allowed in the last position of a `paths` string. // // If a sub-message is specified in the last position of the field mask for an -// update operation, then the existing sub-message in the target resource is -// overwritten. Given the target message: +// update operation, then new value will be merged into the existing sub-message +// in the target resource. +// +// For example, given the target message: // // f { // b { -// d : 1 -// x : 2 +// d: 1 +// x: 2 // } -// c : 1 +// c: [1] // } // // And an update message: // // f { // b { -// d : 10 +// d: 10 // } +// c: [2] // } // // then if the field mask is: // -// paths: "f.b" +// paths: ["f.b", "f.c"] // // then the result will be: // // f { // b { -// d : 10 +// d: 10 +// x: 2 // } -// c : 1 +// c: [1, 2] // } // -// However, if the update mask was: -// -// paths: "f.b.d" -// -// then the result would be: -// -// f { -// b { -// d : 10 -// x : 2 -// } -// c : 1 -// } +// An implementation may provide options to override this default behavior for +// repeated and message fields. // // In order to reset a field's value to the default, the field must // be in the mask and set to the default value in the provided resource. @@ -243,9 +236,9 @@ option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; // // ## Field Mask Verification // -// The implementation of the all the API methods, which have any FieldMask type -// field in the request, should verify the included field paths, and return -// `INVALID_ARGUMENT` error if any path is duplicated or unmappable. +// The implementation of any API method which has a FieldMask type field in the +// request should verify the included field paths, and return an +// `INVALID_ARGUMENT` error if any path is unmappable. message FieldMask { // The set of field mask paths. repeated string paths = 1; diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/source_context.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/source_context.proto similarity index 96% rename from bin/protoc-3.5.1-win32/include/google/protobuf/source_context.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/source_context.proto index f3b2c96..06bfc43 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/source_context.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/source_context.proto @@ -37,7 +37,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "SourceContextProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/source_context;source_context"; +option go_package = "google.golang.org/protobuf/types/known/sourcecontextpb"; // `SourceContext` represents information about the source of a // protobuf element, like the file in which it is defined. diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/struct.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/struct.proto similarity index 96% rename from bin/protoc-3.5.1-win32/include/google/protobuf/struct.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/struct.proto index 7d7808e..0ac843c 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/struct.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/struct.proto @@ -34,13 +34,12 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; +option go_package = "google.golang.org/protobuf/types/known/structpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "StructProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; - // `Struct` represents a structured data value, consisting of fields // which map to dynamically typed values. In some languages, `Struct` // might be supported by a native representation. For example, in @@ -56,8 +55,8 @@ message Struct { // `Value` represents a dynamically typed value which can be either // null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of that -// variants, absence of any variant indicates an error. +// list of values. A producer of value is expected to set one of these +// variants. Absence of any variant indicates an error. // // The JSON representation for `Value` is JSON value. message Value { diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/timestamp.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/timestamp.proto similarity index 71% rename from bin/protoc-3.5.1-win32/include/google/protobuf/timestamp.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/timestamp.proto index 06750ab..3b2df6d 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/timestamp.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/timestamp.proto @@ -34,23 +34,25 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/timestamp"; +option go_package = "google.golang.org/protobuf/types/known/timestamppb"; option java_package = "com.google.protobuf"; option java_outer_classname = "TimestampProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -// A Timestamp represents a point in time independent of any time zone -// or calendar, represented as seconds and fractions of seconds at -// nanosecond resolution in UTC Epoch time. It is encoded using the -// Proleptic Gregorian Calendar which extends the Gregorian calendar -// backwards to year one. It is encoded assuming all minutes are 60 -// seconds long, i.e. leap seconds are "smeared" so that no leap second -// table is needed for interpretation. Range is from -// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. -// By restricting to that range, we ensure that we can convert to -// and from RFC 3339 date strings. -// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). +// A Timestamp represents a point in time independent of any time zone or local +// calendar, encoded as a count of seconds and fractions of seconds at +// nanosecond resolution. The count is relative to an epoch at UTC midnight on +// January 1, 1970, in the proleptic Gregorian calendar which extends the +// Gregorian calendar backwards to year one. +// +// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap +// second table is needed for interpretation, using a [24-hour linear +// smear](https://developers.google.com/time/smear). +// +// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By +// restricting to that range, we ensure that we can convert to and from [RFC +// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. // // # Examples // @@ -89,7 +91,16 @@ option objc_class_prefix = "GPB"; // .setNanos((int) ((millis % 1000) * 1000000)).build(); // // -// Example 5: Compute Timestamp from current time in Python. +// Example 5: Compute Timestamp from Java `Instant.now()`. +// +// Instant now = Instant.now(); +// +// Timestamp timestamp = +// Timestamp.newBuilder().setSeconds(now.getEpochSecond()) +// .setNanos(now.getNano()).build(); +// +// +// Example 6: Compute Timestamp from current time in Python. // // timestamp = Timestamp() // timestamp.GetCurrentTime() @@ -103,23 +114,26 @@ option objc_class_prefix = "GPB"; // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone -// is required, though only UTC (as indicated by "Z") is presently supported. +// is required. A proto3 JSON serializer should always use UTC (as indicated by +// "Z") when printing the Timestamp type and a proto3 JSON parser should be +// able to accept both UTC and other timezones (as indicated by an offset). // // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past // 01:30 UTC on January 15, 2017. // // In JavaScript, one can convert a Date object to this format using the -// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] +// standard +// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) // method. In Python, a standard `datetime.datetime` object can be converted -// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) -// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one -// can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( -// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--) -// to obtain a formatter capable of generating timestamps in this format. +// to this format using +// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with +// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use +// the Joda Time's [`ISODateTimeFormat.dateTime()`]( +// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D +// ) to obtain a formatter capable of generating timestamps in this format. // // message Timestamp { - // Represents seconds of UTC time since Unix epoch // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to // 9999-12-31T23:59:59Z inclusive. diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/type.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/type.proto similarity index 89% rename from bin/protoc-3.5.1-win32/include/google/protobuf/type.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/type.proto index 624c15e..d3f6a68 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/type.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/type.proto @@ -41,7 +41,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "TypeProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/ptype;ptype"; +option go_package = "google.golang.org/protobuf/types/known/typepb"; // A protocol buffer message type. message Type { @@ -64,44 +64,44 @@ message Field { // Basic field types. enum Kind { // Field type unknown. - TYPE_UNKNOWN = 0; + TYPE_UNKNOWN = 0; // Field type double. - TYPE_DOUBLE = 1; + TYPE_DOUBLE = 1; // Field type float. - TYPE_FLOAT = 2; + TYPE_FLOAT = 2; // Field type int64. - TYPE_INT64 = 3; + TYPE_INT64 = 3; // Field type uint64. - TYPE_UINT64 = 4; + TYPE_UINT64 = 4; // Field type int32. - TYPE_INT32 = 5; + TYPE_INT32 = 5; // Field type fixed64. - TYPE_FIXED64 = 6; + TYPE_FIXED64 = 6; // Field type fixed32. - TYPE_FIXED32 = 7; + TYPE_FIXED32 = 7; // Field type bool. - TYPE_BOOL = 8; + TYPE_BOOL = 8; // Field type string. - TYPE_STRING = 9; + TYPE_STRING = 9; // Field type group. Proto2 syntax only, and deprecated. - TYPE_GROUP = 10; + TYPE_GROUP = 10; // Field type message. - TYPE_MESSAGE = 11; + TYPE_MESSAGE = 11; // Field type bytes. - TYPE_BYTES = 12; + TYPE_BYTES = 12; // Field type uint32. - TYPE_UINT32 = 13; + TYPE_UINT32 = 13; // Field type enum. - TYPE_ENUM = 14; + TYPE_ENUM = 14; // Field type sfixed32. - TYPE_SFIXED32 = 15; + TYPE_SFIXED32 = 15; // Field type sfixed64. - TYPE_SFIXED64 = 16; + TYPE_SFIXED64 = 16; // Field type sint32. - TYPE_SINT32 = 17; + TYPE_SINT32 = 17; // Field type sint64. - TYPE_SINT64 = 18; - }; + TYPE_SINT64 = 18; + } // Whether a field is optional, required, or repeated. enum Cardinality { @@ -113,7 +113,7 @@ message Field { CARDINALITY_REQUIRED = 2; // For repeated fields. CARDINALITY_REPEATED = 3; - }; + } // The field type. Kind kind = 1; diff --git a/bin/protoc-3.5.1-win32/include/google/protobuf/wrappers.proto b/bin/protoc-3.19.4-win64/include/google/protobuf/wrappers.proto similarity index 91% rename from bin/protoc-3.5.1-win32/include/google/protobuf/wrappers.proto rename to bin/protoc-3.19.4-win64/include/google/protobuf/wrappers.proto index 0194763..d49dd53 100644 --- a/bin/protoc-3.5.1-win32/include/google/protobuf/wrappers.proto +++ b/bin/protoc-3.19.4-win64/include/google/protobuf/wrappers.proto @@ -32,6 +32,11 @@ // for embedding primitives in the `google.protobuf.Any` type and for places // where we need to distinguish between the absence of a primitive // typed field and its default value. +// +// These wrappers have no meaningful use within repeated fields as they lack +// the ability to detect presence on individual elements. +// These wrappers have no meaningful use within a map or a oneof since +// individual entries of a map or fields of a oneof can already detect presence. syntax = "proto3"; @@ -39,7 +44,7 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/wrappers"; +option go_package = "google.golang.org/protobuf/types/known/wrapperspb"; option java_package = "com.google.protobuf"; option java_outer_classname = "WrappersProto"; option java_multiple_files = true; diff --git a/bin/protoc-3.5.1-win32/readme.txt b/bin/protoc-3.19.4-win64/readme.txt similarity index 93% rename from bin/protoc-3.5.1-win32/readme.txt rename to bin/protoc-3.19.4-win64/readme.txt index e1a718d..b6c9f9b 100644 --- a/bin/protoc-3.5.1-win32/readme.txt +++ b/bin/protoc-3.19.4-win64/readme.txt @@ -12,4 +12,4 @@ copy the contents of the 'include' directory somewhere as well, for example into '/usr/local/include/'. Please refer to our official github site for more installation instructions: - https://github.com/google/protobuf + https://github.com/protocolbuffers/protobuf diff --git a/bin/protoc-3.5.1-win32/bin/protoc.exe b/bin/protoc-3.5.1-win32/bin/protoc.exe deleted file mode 100644 index 16bc9c3..0000000 Binary files a/bin/protoc-3.5.1-win32/bin/protoc.exe and /dev/null differ diff --git a/bin/protoc-gen-go.exe b/bin/protoc-gen-go.exe index 2a8619b..78bb22a 100644 Binary files a/bin/protoc-gen-go.exe and b/bin/protoc-gen-go.exe differ diff --git a/core/builtin/gen_go.bat b/core/builtin/gen_go.bat index d996024..2fce930 100644 --- a/core/builtin/gen_go.bat +++ b/core/builtin/gen_go.bat @@ -1,7 +1,7 @@ @echo off set work_path=%cd% set proto_path=%cd%\protocol -set protoc3=%cd%\..\..\bin\protoc-3.5.1-win32\bin\protoc.exe +set protoc3=%cd%\..\..\bin\protoc-3.19.4-win64\bin\protoc.exe set protoc-gen-go-plugin-path="%cd%\..\..\bin\protoc-gen-go.exe" cd %proto_path% diff --git a/core/builtin/protocol/corepacketid.pb.go b/core/builtin/protocol/corepacketid.pb.go index d0a113f..2edf8d6 100644 --- a/core/builtin/protocol/corepacketid.pb.go +++ b/core/builtin/protocol/corepacketid.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: corepacketid.proto package protocol diff --git a/core/builtin/protocol/corepacketid.proto b/core/builtin/protocol/corepacketid.proto index d87041a..c3f07ca 100644 --- a/core/builtin/protocol/corepacketid.proto +++ b/core/builtin/protocol/corepacketid.proto @@ -3,7 +3,7 @@ package protocol; option go_package = ".;protocol"; enum CoreBuiltinPacketID { - PACKET_COREBUILTIN_UNKNOW = 0; + PACKET_COREBUILTIN_UNKNOW = 0; PACKET_SS_TX_START = -1000; PACKET_SS_TX_CMD = -1001; PACKET_SS_TX_RESULT = -1002; diff --git a/core/builtin/protocol/goserver_rpc.pb.go b/core/builtin/protocol/goserver_rpc.pb.go index 9b75ad5..9198e14 100644 --- a/core/builtin/protocol/goserver_rpc.pb.go +++ b/core/builtin/protocol/goserver_rpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: goserver_rpc.proto package protocol diff --git a/core/builtin/protocol/keepalive.pb.go b/core/builtin/protocol/keepalive.pb.go index ae97b05..66c6685 100644 --- a/core/builtin/protocol/keepalive.pb.go +++ b/core/builtin/protocol/keepalive.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: keepalive.proto package protocol diff --git a/core/builtin/protocol/sessionauth.pb.go b/core/builtin/protocol/sessionauth.pb.go index 6a20663..26927ef 100644 --- a/core/builtin/protocol/sessionauth.pb.go +++ b/core/builtin/protocol/sessionauth.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: sessionauth.proto package protocol diff --git a/core/builtin/protocol/slices.pb.go b/core/builtin/protocol/slices.pb.go index 738dab2..5afd53a 100644 --- a/core/builtin/protocol/slices.pb.go +++ b/core/builtin/protocol/slices.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: slices.proto package protocol diff --git a/core/builtin/protocol/transact.pb.go b/core/builtin/protocol/transact.pb.go index e2a8eaf..b5054c3 100644 --- a/core/builtin/protocol/transact.pb.go +++ b/core/builtin/protocol/transact.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: transact.proto package protocol diff --git a/srvlib/action/broadcasethandler.go b/srvlib/action/broadcasethandler.go new file mode 100644 index 0000000..9696812 --- /dev/null +++ b/srvlib/action/broadcasethandler.go @@ -0,0 +1,45 @@ +package action + +import ( + "google.golang.org/protobuf/proto" + + "mongo.games.com/goserver/core/logger" + "mongo.games.com/goserver/core/netlib" + "mongo.games.com/goserver/srvlib" + "mongo.games.com/goserver/srvlib/protocol" +) + +func init() { + netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), &protocol.SSPacketBroadcast{}, BroadcastHandler) +} + +func BroadcastHandler(s *netlib.Session, packetId int, data interface{}) error { + if bp, ok := data.(*protocol.SSPacketBroadcast); ok { + pd := bp.GetData() + sp := bp.GetSessParam() + if bcss := sp.GetBcss(); bcss != nil { + srvlib.ServerSessionMgrSington.Broadcast(int(bp.GetPacketId()), pd, int(bcss.GetSArea()), int(bcss.GetSType())) + } + } + return nil +} + +func CreateBroadcastPacket(sp *protocol.BCSessionUnion, packetId int, data interface{}) (proto.Message, error) { + pack := &protocol.SSPacketBroadcast{ + SessParam: sp, + PacketId: int32(packetId), + } + + if byteData, ok := data.([]byte); ok { + pack.Data = byteData + } else { + byteData, err := netlib.MarshalPacket(packetId, data) + if err == nil { + pack.Data = byteData + } else { + logger.Logger.Warnf("CreateBroadcastPacket err:%v", err) + return nil, err + } + } + return pack, nil +} diff --git a/srvlib/action/multicasthhandler.go b/srvlib/action/multicasthhandler.go new file mode 100644 index 0000000..852e1de --- /dev/null +++ b/srvlib/action/multicasthhandler.go @@ -0,0 +1,39 @@ +package action + +import ( + "mongo.games.com/goserver/core/netlib" + "mongo.games.com/goserver/srvlib" + "mongo.games.com/goserver/srvlib/protocol" +) + +func init() { + netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), &protocol.SSPacketMulticast{}, MulticastHandler) +} + +func MulticastHandler(s *netlib.Session, packetid int, data interface{}) error { + if mp, ok := data.(*protocol.SSPacketMulticast); ok { + pd := mp.GetData() + sis := mp.GetSessions() + for _, si := range sis { + ns := getSession(si) + if ns != nil { + ns.Send(int(mp.GetPacketId()), pd) + } + } + } + return nil +} + +func getSession(su *protocol.MCSessionUnion) *netlib.Session { + cs := su.GetMccs() + if cs != nil { + return srvlib.ClientSessionMgrSington.GetSession(cs.GetSId()) + } + + ss := su.GetMcss() + if ss != nil { + return srvlib.ServerSessionMgrSington.GetSession(int(ss.GetSArea()), int(ss.GetSType()), int(ss.GetSId())) + } + + return nil +} diff --git a/srvlib/action/redirecthandler.go b/srvlib/action/redirecthandler.go deleted file mode 100644 index 42184fb..0000000 --- a/srvlib/action/redirecthandler.go +++ /dev/null @@ -1,44 +0,0 @@ -package action - -import ( - "mongo.games.com/goserver/core/logger" - "mongo.games.com/goserver/core/netlib" - "mongo.games.com/goserver/srvlib" - "mongo.games.com/goserver/srvlib/protocol" -) - -type PacketRedirectPacketFactory struct { -} - -type PacketRedirectHandler struct { -} - -func init() { - netlib.RegisterHandler(int(protocol.SrvlibPacketID_PACKET_SS_REDIRECT), &PacketRedirectHandler{}) - netlib.RegisterFactory(int(protocol.SrvlibPacketID_PACKET_SS_REDIRECT), &PacketRedirectPacketFactory{}) -} - -func (this *PacketRedirectPacketFactory) CreatePacket() interface{} { - pack := &protocol.SSPacketRedirect{} - return pack -} - -func (this *PacketRedirectHandler) Process(s *netlib.Session, packetid int, data interface{}) error { - logger.Logger.Trace("PacketRedirectHandler.Process") - if pr, ok := data.(*protocol.SSPacketRedirect); ok { - packid, pack, err := netlib.UnmarshalPacket(pr.GetData()) - if err != nil { - return err - } - h := srvlib.GetHandler(packid) - if h != nil { - return h.Process(s, packid, pack, pr.GetClientSid(), pr.GetSrvRoutes()) - } else { - nh := netlib.GetHandler(packid) - if nh != nil { - return nh.Process(s, packid, pack) - } - } - } - return nil -} diff --git a/srvlib/action/transithandler.go b/srvlib/action/transithandler.go deleted file mode 100644 index dd20a89..0000000 --- a/srvlib/action/transithandler.go +++ /dev/null @@ -1,35 +0,0 @@ -package action - -import ( - "mongo.games.com/goserver/core/logger" - "mongo.games.com/goserver/core/netlib" - "mongo.games.com/goserver/srvlib" - "mongo.games.com/goserver/srvlib/protocol" -) - -type PacketTransitPacketFactory struct { -} - -type PacketTransitHandler struct { -} - -func init() { - netlib.RegisterHandler(int(protocol.SrvlibPacketID_PACKET_SS_TRANSIT), &PacketTransitHandler{}) - netlib.RegisterFactory(int(protocol.SrvlibPacketID_PACKET_SS_TRANSIT), &PacketTransitPacketFactory{}) -} - -func (this *PacketTransitPacketFactory) CreatePacket() interface{} { - pack := &protocol.SSPacketTransit{} - return pack -} - -func (this *PacketTransitHandler) Process(s *netlib.Session, packetid int, data interface{}) error { - logger.Logger.Trace("PacketTransitHandler.Process") - if pr, ok := data.(*protocol.SSPacketTransit); ok { - targetS := srvlib.ServerSessionMgrSington.GetSession(int(pr.GetSArea()), int(pr.GetSType()), int(pr.GetSId())) - if targetS != nil { - targetS.Send(int(pr.GetPacketId()), pr.GetData()) - } - } - return nil -} diff --git a/srvlib/gen_go.bat b/srvlib/gen_go.bat index 128e44b..caa5d4e 100644 --- a/srvlib/gen_go.bat +++ b/srvlib/gen_go.bat @@ -1,7 +1,7 @@ @echo off set work_path=%cd% set proto_path=%cd%\protocol -set protoc3=%cd%\..\bin\protoc-3.5.1-win32\bin\protoc.exe +set protoc3=%cd%\..\bin\protoc-3.19.4-win64\bin\protoc.exe set protoc-gen-go-plugin-path="%cd%\..\bin\protoc-gen-go.exe" cd %proto_path% diff --git a/srvlib/handler.go b/srvlib/handler.go deleted file mode 100644 index feb89bd..0000000 --- a/srvlib/handler.go +++ /dev/null @@ -1,49 +0,0 @@ -package srvlib - -import ( - "fmt" - "reflect" - - "mongo.games.com/goserver/core/netlib" - "mongo.games.com/goserver/srvlib/protocol" -) - -var handlers = make(map[int]Handler) - -type Handler interface { - Process(s *netlib.Session, packetid int, data interface{}, sid int64, routes []*protocol.SrvInfo) error -} - -type HandlerWrapper func(s *netlib.Session, packetid int, data interface{}, sid int64, routes []*protocol.SrvInfo) error - -func (hw HandlerWrapper) Process(s *netlib.Session, packetid int, data interface{}, sid int64, routes []*protocol.SrvInfo) error { - return hw(s, packetid, data, sid, routes) -} - -func RegisterHandler(packetId int, h Handler) { - if _, ok := handlers[packetId]; ok { - panic(fmt.Sprintf("repeate register handler: %v Handler type=%v", packetId, reflect.TypeOf(h))) - } - - handlers[packetId] = h -} - -func Register1ToMHandler(h Handler, packetIds ...int) { - for _, packetId := range packetIds { - RegisterHandler(packetId, h) - } -} - -func RegisterRangeHandler(start, end int, h Handler) { - for ; start <= end; start++ { - RegisterHandler(start, h) - } -} - -func GetHandler(packetId int) Handler { - if h, ok := handlers[packetId]; ok { - return h - } - - return nil -} diff --git a/srvlib/protocol/broadcast.pb.go b/srvlib/protocol/broadcast.pb.go index 6832acf..fabbe91 100644 --- a/srvlib/protocol/broadcast.pb.go +++ b/srvlib/protocol/broadcast.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: broadcast.proto package protocol diff --git a/srvlib/protocol/multicast.pb.go b/srvlib/protocol/multicast.pb.go index 7f1a8e5..a7ec7b6 100644 --- a/srvlib/protocol/multicast.pb.go +++ b/srvlib/protocol/multicast.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: multicast.proto package protocol diff --git a/srvlib/protocol/redirect.pb.go b/srvlib/protocol/redirect.pb.go deleted file mode 100644 index 5af258b..0000000 --- a/srvlib/protocol/redirect.pb.go +++ /dev/null @@ -1,254 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 -// source: redirect.proto - -package protocol - -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 SSPacketRedirect struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ClientSid int64 `protobuf:"varint,1,opt,name=ClientSid,proto3" json:"ClientSid,omitempty"` - SrvRoutes []*SrvInfo `protobuf:"bytes,2,rep,name=SrvRoutes,proto3" json:"SrvRoutes,omitempty"` - PacketId int32 `protobuf:"varint,3,opt,name=PacketId,proto3" json:"PacketId,omitempty"` - Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"` -} - -func (x *SSPacketRedirect) Reset() { - *x = SSPacketRedirect{} - if protoimpl.UnsafeEnabled { - mi := &file_redirect_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SSPacketRedirect) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SSPacketRedirect) ProtoMessage() {} - -func (x *SSPacketRedirect) ProtoReflect() protoreflect.Message { - mi := &file_redirect_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 SSPacketRedirect.ProtoReflect.Descriptor instead. -func (*SSPacketRedirect) Descriptor() ([]byte, []int) { - return file_redirect_proto_rawDescGZIP(), []int{0} -} - -func (x *SSPacketRedirect) GetClientSid() int64 { - if x != nil { - return x.ClientSid - } - return 0 -} - -func (x *SSPacketRedirect) GetSrvRoutes() []*SrvInfo { - if x != nil { - return x.SrvRoutes - } - return nil -} - -func (x *SSPacketRedirect) GetPacketId() int32 { - if x != nil { - return x.PacketId - } - return 0 -} - -func (x *SSPacketRedirect) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -type SrvInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SArea int32 `protobuf:"varint,1,opt,name=SArea,proto3" json:"SArea,omitempty"` - SType int32 `protobuf:"varint,2,opt,name=SType,proto3" json:"SType,omitempty"` - SId int32 `protobuf:"varint,3,opt,name=SId,proto3" json:"SId,omitempty"` -} - -func (x *SrvInfo) Reset() { - *x = SrvInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_redirect_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SrvInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SrvInfo) ProtoMessage() {} - -func (x *SrvInfo) ProtoReflect() protoreflect.Message { - mi := &file_redirect_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 SrvInfo.ProtoReflect.Descriptor instead. -func (*SrvInfo) Descriptor() ([]byte, []int) { - return file_redirect_proto_rawDescGZIP(), []int{1} -} - -func (x *SrvInfo) GetSArea() int32 { - if x != nil { - return x.SArea - } - return 0 -} - -func (x *SrvInfo) GetSType() int32 { - if x != nil { - return x.SType - } - return 0 -} - -func (x *SrvInfo) GetSId() int32 { - if x != nil { - return x.SId - } - return 0 -} - -var File_redirect_proto protoreflect.FileDescriptor - -var file_redirect_proto_rawDesc = []byte{ - 0x0a, 0x0e, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x91, 0x01, 0x0a, 0x10, 0x53, - 0x53, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x12, - 0x1c, 0x0a, 0x09, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x69, 0x64, 0x12, 0x2f, 0x0a, - 0x09, 0x53, 0x72, 0x76, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x72, 0x76, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x53, 0x72, 0x76, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x12, 0x1a, - 0x0a, 0x08, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x08, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, - 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x47, - 0x0a, 0x07, 0x53, 0x72, 0x76, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x53, 0x41, 0x72, - 0x65, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x53, 0x41, 0x72, 0x65, 0x61, 0x12, - 0x14, 0x0a, 0x05, 0x53, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x53, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x03, 0x53, 0x49, 0x64, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x3b, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_redirect_proto_rawDescOnce sync.Once - file_redirect_proto_rawDescData = file_redirect_proto_rawDesc -) - -func file_redirect_proto_rawDescGZIP() []byte { - file_redirect_proto_rawDescOnce.Do(func() { - file_redirect_proto_rawDescData = protoimpl.X.CompressGZIP(file_redirect_proto_rawDescData) - }) - return file_redirect_proto_rawDescData -} - -var file_redirect_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_redirect_proto_goTypes = []interface{}{ - (*SSPacketRedirect)(nil), // 0: protocol.SSPacketRedirect - (*SrvInfo)(nil), // 1: protocol.SrvInfo -} -var file_redirect_proto_depIdxs = []int32{ - 1, // 0: protocol.SSPacketRedirect.SrvRoutes:type_name -> protocol.SrvInfo - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_redirect_proto_init() } -func file_redirect_proto_init() { - if File_redirect_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_redirect_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SSPacketRedirect); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_redirect_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SrvInfo); 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_redirect_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_redirect_proto_goTypes, - DependencyIndexes: file_redirect_proto_depIdxs, - MessageInfos: file_redirect_proto_msgTypes, - }.Build() - File_redirect_proto = out.File - file_redirect_proto_rawDesc = nil - file_redirect_proto_goTypes = nil - file_redirect_proto_depIdxs = nil -} diff --git a/srvlib/protocol/redirect.proto b/srvlib/protocol/redirect.proto deleted file mode 100644 index a67d8f7..0000000 --- a/srvlib/protocol/redirect.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; -package protocol; -option go_package = ".;protocol"; - -message SSPacketRedirect { - int64 ClientSid = 1; - repeated SrvInfo SrvRoutes = 2; - int32 PacketId = 3; - bytes Data = 4; -} - -message SrvInfo { - int32 SArea = 1; - int32 SType = 2; - int32 SId = 3; -} \ No newline at end of file diff --git a/srvlib/protocol/serviceinfo.pb.go b/srvlib/protocol/serviceinfo.pb.go index 090bdfd..ef0c403 100644 --- a/srvlib/protocol/serviceinfo.pb.go +++ b/srvlib/protocol/serviceinfo.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: serviceinfo.proto package protocol diff --git a/srvlib/protocol/srvlibpacketid.pb.go b/srvlib/protocol/srvlibpacketid.pb.go index 3f69ff4..18f75f0 100644 --- a/srvlib/protocol/srvlibpacketid.pb.go +++ b/srvlib/protocol/srvlibpacketid.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: srvlibpacketid.proto package protocol @@ -26,12 +26,10 @@ const ( SrvlibPacketID_PACKET_SRVLIB_UNKNOW SrvlibPacketID = 0 SrvlibPacketID_PACKET_SS_REGISTE SrvlibPacketID = -2000 SrvlibPacketID_PACKET_SS_MULTICAST SrvlibPacketID = -2001 - SrvlibPacketID_PACKET_SS_BROADCAST SrvlibPacketID = -2002 - SrvlibPacketID_PACKET_SS_TRANSIT SrvlibPacketID = -2003 - SrvlibPacketID_PACKET_SS_REDIRECT SrvlibPacketID = -2004 - SrvlibPacketID_PACKET_SS_SERVICE_REGISTE SrvlibPacketID = -2005 - SrvlibPacketID_PACKET_SS_SERVICE_INFO SrvlibPacketID = -2006 - SrvlibPacketID_PACKET_SS_SERVICE_SHUT SrvlibPacketID = -2007 + SrvlibPacketID_PACKET_SS_BROADCAST SrvlibPacketID = -2002 // 消息广播;给一个 + SrvlibPacketID_PACKET_SS_SERVICE_REGISTE SrvlibPacketID = -2003 + SrvlibPacketID_PACKET_SS_SERVICE_INFO SrvlibPacketID = -2004 + SrvlibPacketID_PACKET_SS_SERVICE_SHUT SrvlibPacketID = -2005 ) // Enum value maps for SrvlibPacketID. @@ -41,22 +39,18 @@ var ( -2000: "PACKET_SS_REGISTE", -2001: "PACKET_SS_MULTICAST", -2002: "PACKET_SS_BROADCAST", - -2003: "PACKET_SS_TRANSIT", - -2004: "PACKET_SS_REDIRECT", - -2005: "PACKET_SS_SERVICE_REGISTE", - -2006: "PACKET_SS_SERVICE_INFO", - -2007: "PACKET_SS_SERVICE_SHUT", + -2003: "PACKET_SS_SERVICE_REGISTE", + -2004: "PACKET_SS_SERVICE_INFO", + -2005: "PACKET_SS_SERVICE_SHUT", } SrvlibPacketID_value = map[string]int32{ "PACKET_SRVLIB_UNKNOW": 0, "PACKET_SS_REGISTE": -2000, "PACKET_SS_MULTICAST": -2001, "PACKET_SS_BROADCAST": -2002, - "PACKET_SS_TRANSIT": -2003, - "PACKET_SS_REDIRECT": -2004, - "PACKET_SS_SERVICE_REGISTE": -2005, - "PACKET_SS_SERVICE_INFO": -2006, - "PACKET_SS_SERVICE_SHUT": -2007, + "PACKET_SS_SERVICE_REGISTE": -2003, + "PACKET_SS_SERVICE_INFO": -2004, + "PACKET_SS_SERVICE_SHUT": -2005, } ) @@ -92,7 +86,7 @@ var File_srvlibpacketid_proto protoreflect.FileDescriptor var file_srvlibpacketid_proto_rawDesc = []byte{ 0x0a, 0x14, 0x73, 0x72, 0x76, 0x6c, 0x69, 0x62, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x2a, 0xc1, 0x02, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x6c, 0x69, 0x62, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x2a, 0x80, 0x02, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x6c, 0x69, 0x62, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x52, 0x56, 0x4c, 0x49, 0x42, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x11, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, @@ -101,19 +95,15 @@ var file_srvlibpacketid_proto_rawDesc = []byte{ 0x43, 0x41, 0x53, 0x54, 0x10, 0xaf, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x12, 0x20, 0x0a, 0x13, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x42, 0x52, 0x4f, 0x41, 0x44, 0x43, 0x41, 0x53, 0x54, 0x10, 0xae, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x12, 0x1e, 0x0a, 0x11, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x54, - 0x52, 0x41, 0x4e, 0x53, 0x49, 0x54, 0x10, 0xad, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x12, 0x1f, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x52, - 0x45, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x10, 0xac, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x01, 0x12, 0x26, 0x0a, 0x19, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, - 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x10, - 0xab, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x12, 0x23, 0x0a, 0x16, 0x50, 0x41, - 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, - 0x49, 0x4e, 0x46, 0x4f, 0x10, 0xaa, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x12, - 0x23, 0x0a, 0x16, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x53, 0x45, 0x52, - 0x56, 0x49, 0x43, 0x45, 0x5f, 0x53, 0x48, 0x55, 0x54, 0x10, 0xa9, 0xf0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x01, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x12, 0x26, 0x0a, 0x19, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x53, + 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x10, 0xad, + 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x12, 0x23, 0x0a, 0x16, 0x50, 0x41, 0x43, + 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x49, + 0x4e, 0x46, 0x4f, 0x10, 0xac, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x12, 0x23, + 0x0a, 0x16, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x53, 0x5f, 0x53, 0x45, 0x52, 0x56, + 0x49, 0x43, 0x45, 0x5f, 0x53, 0x48, 0x55, 0x54, 0x10, 0xab, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/srvlib/protocol/srvlibpacketid.proto b/srvlib/protocol/srvlibpacketid.proto index c3716d6..fc98ee9 100644 --- a/srvlib/protocol/srvlibpacketid.proto +++ b/srvlib/protocol/srvlibpacketid.proto @@ -3,13 +3,11 @@ package protocol; option go_package = ".;protocol"; enum SrvlibPacketID { - PACKET_SRVLIB_UNKNOW= 0; + PACKET_SRVLIB_UNKNOW= 0; PACKET_SS_REGISTE = -2000; PACKET_SS_MULTICAST = -2001; PACKET_SS_BROADCAST = -2002; // 消息广播;给一个 - PACKET_SS_TRANSIT = -2003; - PACKET_SS_REDIRECT = -2004; - PACKET_SS_SERVICE_REGISTE = -2005; - PACKET_SS_SERVICE_INFO = -2006; - PACKET_SS_SERVICE_SHUT = -2007; + PACKET_SS_SERVICE_REGISTE = -2003; + PACKET_SS_SERVICE_INFO = -2004; + PACKET_SS_SERVICE_SHUT = -2005; } \ No newline at end of file diff --git a/srvlib/protocol/srvregiste.pb.go b/srvlib/protocol/srvregiste.pb.go index c478792..f057b0b 100644 --- a/srvlib/protocol/srvregiste.pb.go +++ b/srvlib/protocol/srvregiste.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 +// protoc-gen-go v1.27.1-devel +// protoc v3.19.4 // source: srvregiste.proto package protocol diff --git a/srvlib/protocol/transit.pb.go b/srvlib/protocol/transit.pb.go deleted file mode 100644 index 897f942..0000000 --- a/srvlib/protocol/transit.pb.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.5.1 -// source: transit.proto - -package protocol - -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 SSPacketTransit struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SArea int32 `protobuf:"varint,1,opt,name=SArea,proto3" json:"SArea,omitempty"` - SType int32 `protobuf:"varint,2,opt,name=SType,proto3" json:"SType,omitempty"` - SId int32 `protobuf:"varint,3,opt,name=SId,proto3" json:"SId,omitempty"` - PacketId int32 `protobuf:"varint,4,opt,name=PacketId,proto3" json:"PacketId,omitempty"` - Data []byte `protobuf:"bytes,5,opt,name=Data,proto3" json:"Data,omitempty"` -} - -func (x *SSPacketTransit) Reset() { - *x = SSPacketTransit{} - if protoimpl.UnsafeEnabled { - mi := &file_transit_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SSPacketTransit) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SSPacketTransit) ProtoMessage() {} - -func (x *SSPacketTransit) ProtoReflect() protoreflect.Message { - mi := &file_transit_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 SSPacketTransit.ProtoReflect.Descriptor instead. -func (*SSPacketTransit) Descriptor() ([]byte, []int) { - return file_transit_proto_rawDescGZIP(), []int{0} -} - -func (x *SSPacketTransit) GetSArea() int32 { - if x != nil { - return x.SArea - } - return 0 -} - -func (x *SSPacketTransit) GetSType() int32 { - if x != nil { - return x.SType - } - return 0 -} - -func (x *SSPacketTransit) GetSId() int32 { - if x != nil { - return x.SId - } - return 0 -} - -func (x *SSPacketTransit) GetPacketId() int32 { - if x != nil { - return x.PacketId - } - return 0 -} - -func (x *SSPacketTransit) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -var File_transit_proto protoreflect.FileDescriptor - -var file_transit_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x7f, 0x0a, 0x0f, 0x53, 0x53, 0x50, - 0x61, 0x63, 0x6b, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x53, 0x41, 0x72, 0x65, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x53, 0x41, 0x72, - 0x65, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x53, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x05, 0x53, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x49, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x53, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, - 0x63, 0x6b, 0x65, 0x74, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x50, 0x61, - 0x63, 0x6b, 0x65, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x3b, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_transit_proto_rawDescOnce sync.Once - file_transit_proto_rawDescData = file_transit_proto_rawDesc -) - -func file_transit_proto_rawDescGZIP() []byte { - file_transit_proto_rawDescOnce.Do(func() { - file_transit_proto_rawDescData = protoimpl.X.CompressGZIP(file_transit_proto_rawDescData) - }) - return file_transit_proto_rawDescData -} - -var file_transit_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transit_proto_goTypes = []interface{}{ - (*SSPacketTransit)(nil), // 0: protocol.SSPacketTransit -} -var file_transit_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_transit_proto_init() } -func file_transit_proto_init() { - if File_transit_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_transit_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SSPacketTransit); 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_transit_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_transit_proto_goTypes, - DependencyIndexes: file_transit_proto_depIdxs, - MessageInfos: file_transit_proto_msgTypes, - }.Build() - File_transit_proto = out.File - file_transit_proto_rawDesc = nil - file_transit_proto_goTypes = nil - file_transit_proto_depIdxs = nil -} diff --git a/srvlib/protocol/transit.proto b/srvlib/protocol/transit.proto deleted file mode 100644 index b2bd191..0000000 --- a/srvlib/protocol/transit.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; -package protocol; -option go_package = ".;protocol"; - -message SSPacketTransit { - int32 SArea = 1; - int32 SType = 2; - int32 SId = 3; - int32 PacketId = 4; - bytes Data = 5; -} \ No newline at end of file diff --git a/srvlib/serversessionmgr.go b/srvlib/serversessionmgr.go index a2c18da..8057eac 100644 --- a/srvlib/serversessionmgr.go +++ b/srvlib/serversessionmgr.go @@ -27,11 +27,13 @@ type ServerSessionMgr struct { listeners []ServerSessionRegisteListener } +// AddListener 添加一个服务器会话注册监听器 func (ssm *ServerSessionMgr) AddListener(l ServerSessionRegisteListener) ServerSessionRegisteListener { ssm.listeners = append(ssm.listeners, l) return l } +// RegisteSession 注册一个新的服务器会话 func (ssm *ServerSessionMgr) RegisteSession(s *netlib.Session) bool { attr := s.GetAttribute(SessionAttributeServerInfo) if attr == nil { @@ -58,7 +60,7 @@ func (ssm *ServerSessionMgr) RegisteSession(s *netlib.Session) bool { session, has := ssm.sessions[areaId][srvType][srvId] if has && session != nil && session != s { - logger.Logger.Warnf("删除旧服务器注册: %v", srvInfo) + logger.Logger.Infof("删除旧服务器注册: %v", srvInfo) ssm.UnregisteSession(session) } @@ -73,8 +75,7 @@ func (ssm *ServerSessionMgr) RegisteSession(s *netlib.Session) bool { return true } -// UnregisteSession 服务器关闭 -// 需要支持幂等性 +// UnregisteSession 注销一个服务器会话 func (ssm *ServerSessionMgr) UnregisteSession(s *netlib.Session) bool { attr := s.GetAttribute(SessionAttributeServerInfo) if attr == nil { @@ -86,7 +87,7 @@ func (ssm *ServerSessionMgr) UnregisteSession(s *netlib.Session) bool { return false } - logger.Logger.Tracef("尝试删除服务器注册:%v", srvInfo) + logger.Logger.Infof("尝试删除服务器注册:%v", srvInfo) areaId := int(srvInfo.GetAreaId()) srvType := int(srvInfo.GetType()) srvId := int(srvInfo.GetId()) @@ -103,14 +104,18 @@ func (ssm *ServerSessionMgr) UnregisteSession(s *netlib.Session) bool { } return true } else { - logger.Logger.Tracef("服务器注册信息已经删除") + logger.Logger.Infof("服务器注册信息已经删除") + return false } } } + logger.Logger.Infof("服务器注册信息没找到:%v", srvInfo) + return false } +// GetSession 根据区域ID、服务器类型和服务器ID获取会话 func (ssm *ServerSessionMgr) GetSession(areaId, srvType, srvId int) *netlib.Session { if a, exist := ssm.sessions[areaId]; exist { if b, exist := a[srvType]; exist { @@ -122,6 +127,7 @@ func (ssm *ServerSessionMgr) GetSession(areaId, srvType, srvId int) *netlib.Sess return nil } +// GetSessions 获取指定区域和服务器类型的所有会话 func (ssm *ServerSessionMgr) GetSessions(areaId, srvType int) (sessions []*netlib.Session) { if a, exist := ssm.sessions[areaId]; exist { if b, exist := a[srvType]; exist { @@ -133,6 +139,7 @@ func (ssm *ServerSessionMgr) GetSessions(areaId, srvType int) (sessions []*netli return } +// GetServerId 获取指定区域和服务器类型的第一个服务器ID func (ssm *ServerSessionMgr) GetServerId(areaId, srvType int) int { if a, exist := ssm.sessions[areaId]; exist { if b, exist := a[srvType]; exist { @@ -144,6 +151,7 @@ func (ssm *ServerSessionMgr) GetServerId(areaId, srvType int) int { return -1 } +// GetServerIdByMaxData 根据最大数据获取指定区域和服务器类型的服务器ID func (ssm *ServerSessionMgr) GetServerIdByMaxData(areaId, srvType int) int { var bestSid int = -1 var data string @@ -162,9 +170,19 @@ func (ssm *ServerSessionMgr) GetServerIdByMaxData(areaId, srvType int) int { return bestSid } +// GetServerIds 获取指定区域和服务器类型的所有服务器ID +// 参数: +// - areaId: 区域ID +// - srvType: 服务器类型 +// +// 返回: +// - ids: 包含所有匹配服务器ID的切片 func (ssm *ServerSessionMgr) GetServerIds(areaId, srvType int) (ids []int) { + // 检查指定区域是否存在 if a, exist := ssm.sessions[areaId]; exist { + // 检查指定服务器类型是否存在 if b, exist := a[srvType]; exist { + // 遍历所有匹配的服务器,收集它们的ID for sid := range b { ids = append(ids, sid) } @@ -173,9 +191,11 @@ func (ssm *ServerSessionMgr) GetServerIds(areaId, srvType int) (ids []int) { return } +// Broadcast 向指定区域和服务器类型广播消息 func (ssm *ServerSessionMgr) Broadcast(packetid int, pack interface{}, areaId, srvType int) { if areaId >= 0 { if srvType >= 0 { + // 向特定区域和服务器类型广播 if a, exist := ssm.sessions[areaId]; exist { if b, exist := a[srvType]; exist { for _, s := range b { @@ -184,6 +204,7 @@ func (ssm *ServerSessionMgr) Broadcast(packetid int, pack interface{}, areaId, s } } } else { + // 向特定区域的所有服务器类型广播 if a, exist := ssm.sessions[areaId]; exist { for _, b := range a { for _, s := range b { @@ -194,6 +215,7 @@ func (ssm *ServerSessionMgr) Broadcast(packetid int, pack interface{}, areaId, s } } else { if srvType >= 0 { + // 向所有区域的特定服务器类型广播 for _, a := range ssm.sessions { if b, exist := a[srvType]; exist { for _, s := range b { @@ -202,6 +224,7 @@ func (ssm *ServerSessionMgr) Broadcast(packetid int, pack interface{}, areaId, s } } } else { + // 向所有区域的所有服务器类型广播 for _, a := range ssm.sessions { for _, b := range a { for _, s := range b { diff --git a/srvlib/servicemgr.go b/srvlib/servicemgr.go index 59b7477..4abd93f 100644 --- a/srvlib/servicemgr.go +++ b/srvlib/servicemgr.go @@ -47,7 +47,7 @@ func (this *serviceMgr) RegisteService(s *netlib.Session, services []*protocol.S } if _, exist := this.servicesPool[srvtype][srvid]; !exist { this.servicesPool[srvtype][srvid] = service - logger.Logger.Info("(this *serviceMgr) RegisteService: ", service.GetSrvName(), " Ip=", service.GetIp(), " Port=", service.GetPort()) + logger.Logger.Infof("ServiceMgr RegisteService Name:%v Ip:%v Port:%v", service.GetSrvName(), service.GetIp(), service.GetPort()) pack := &protocol.SSServiceInfo{} pack.Service = service sessiontypes := GetCareSessionsByService(service.GetSrvType()) @@ -76,7 +76,7 @@ func (this *serviceMgr) UnregisteService(service *protocol.ServiceInfo) { if v, has := this.servicesPool[srvtype]; has { if ss, exist := v[srvid]; exist && ss == service { delete(v, srvid) - logger.Logger.Info("(this *serviceMgr) UnregisteService: ", srvid) + logger.Logger.Infof("ServiceMgr UnregisteService srvType:%v srvId:%v", srvtype, srvid) pack := &protocol.SSServiceShut{} pack.Service = service sessiontypes := GetCareSessionsByService(service.GetSrvType())