commit d23be4c91e948017fe6c3eb92be3875c5cb1d90a Author: NorthLan <6995syu@163.com> Date: Wed Oct 26 17:23:44 2022 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94a98d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Binaries for programs and plugins +*.exe +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 +.glide/ + +.idea/ +.vscode/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..04855a6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright [2022-2025] [NorthLan] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..c5361ad --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module git.noahlan.cn/northlan/nnet + +go 1.18 + +require google.golang.org/protobuf v1.28.1 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c4b2520 --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/interfaces/i_packet.go b/interfaces/i_packet.go new file mode 100644 index 0000000..b448881 --- /dev/null +++ b/interfaces/i_packet.go @@ -0,0 +1,7 @@ +package interfaces + +// IPacket 面向TCP连接中的数据流,网络数据包抽象接口 +type IPacket interface { + // HeaderLength TCP数据帧头部长度,固定长度值 + HeaderLength() int +} diff --git a/interfaces/i_session.go b/interfaces/i_session.go new file mode 100644 index 0000000..c65a7a7 --- /dev/null +++ b/interfaces/i_session.go @@ -0,0 +1,31 @@ +package interfaces + +// ISessionData Session数据接口 +type ISessionData interface { + // Remove 通过key移除数据 + Remove(key string) + // Set 设置数据 + Set(key string, value interface{}) + // Exists key是否存在 + Exists(key string) bool + // Value 获取指定key的值 + Value(key string) interface{} + // Data 获取所有数据 + Data() map[string]interface{} + // SetData 保存所有数据 + SetData(data map[string]interface{}) + // Clear 清理数据 + Clear() +} + +// ISession session接口 +type ISession interface { + // ID Session ID + ID() int64 + // UID 用户自行绑定UID,默认与SessionID一致 + UID() interface{} + // Bind 绑定用户ID + Bind(uid interface{}) + // ISessionData Session数据抽象方法 + ISessionData +}