diff --git a/README-CN.md b/README-CN.md index 2c68885e..45c09973 100644 --- a/README-CN.md +++ b/README-CN.md @@ -16,7 +16,7 @@ Zinx 是一个基于Golang的轻量级并发服务器框架 [ < Zinx 文档 : 简体中文> ](https://www.yuque.com/aceld/tsgooa/sbvzgczh3hqz8q3l) -> **说明**:目前zinx已经在很多企业进行开发使用,具体使用领域包括:后端模块的消息中转、长链接游戏服务器、Web框架中的消息处理插件等。zinx的定位是代码简洁,让更多的开发者迅速的了解框架的内脏细节并且可以快速基于zinx DIY(二次开发)一款适合自己企业场景的模块。 +> **说明**:目前zinx已经在很多企业进行开发使用,具体使用领域包括:后端模块的消息中转、长连接游戏服务器、Web框架中的消息处理插件等。zinx的定位是代码简洁,让更多的开发者迅速的了解框架的内脏细节并且可以快速基于zinx DIY(二次开发)一款适合自己企业场景的模块。 --- ## zinx源码地址 @@ -52,7 +52,7 @@ http://zinx.me ## 一、写在前面 -我们为什么要做Zinx,Golang目前在服务器的应用框架很多,但是应用在游戏领域或者其他长链接的领域的轻量级企业框架甚少。 +我们为什么要做Zinx,Golang目前在服务器的应用框架很多,但是应用在游戏领域或者其他长连接的领域的轻量级企业框架甚少。 设计Zinx的目的是我们可以通过Zinx框架来了解基于Golang编写一个TCP服务器的整体轮廓,让更多的Golang爱好者能深入浅出的去学习和认识这个领域。 @@ -216,7 +216,7 @@ func main() { //创建Client客户端 client := znet.NewClient("127.0.0.1", 8999) - //设置链接建立成功后的钩子函数 + //设置连接建立成功后的钩子函数 client.SetOnConnStart(onClientStart) //启动客户端 @@ -270,7 +270,7 @@ recv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient] `TcpPort`:服务器监听端口 -`MaxConn`:允许的客户端链接最大数量 +`MaxConn`:允许的客户端连接最大数量 `WorkerPoolSize`:工作任务池最大工作Goroutine数量 diff --git a/examples/zinx_RequestPollMode/client/client.go b/examples/zinx_RequestPollMode/client/client.go index fa49ca86..5809cdd2 100644 --- a/examples/zinx_RequestPollMode/client/client.go +++ b/examples/zinx_RequestPollMode/client/client.go @@ -35,9 +35,9 @@ func business(conn ziface.IConnection) { // Function to execute when the connection is created (创建连接的时候执行) func DoClientConnectedBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") - // Set two connection properties after the connection is created (设置两个链接属性,在连接创建之后) + // Set two connection properties after the connection is created (设置两个连接属性,在连接创建之后) conn.SetProperty("Name", "刘丹冰Aceld") conn.SetProperty("Home", "https://yuque.com/aceld") @@ -64,7 +64,7 @@ func main() { client := znet.NewClient("127.0.0.1", 8999) // Set the business logic to execute when the connection is created or lost - // (添加首次建立链接时的业务) + // (添加首次建立连接时的业务) client.SetOnConnStart(DoClientConnectedBegin) client.SetOnConnStop(DoClientConnectedLost) diff --git a/examples/zinx_client/main.go b/examples/zinx_client/main.go index fddfed33..73499a4e 100644 --- a/examples/zinx_client/main.go +++ b/examples/zinx_client/main.go @@ -34,9 +34,9 @@ func business(conn ziface.IConnection) { // Function to execute when the connection is created (创建连接的时候执行) func DoClientConnectedBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") - // Set two connection properties after the connection is created (设置两个链接属性,在连接创建之后) + // Set two connection properties after the connection is created (设置两个连接属性,在连接创建之后) conn.SetProperty("Name", "刘丹冰Aceld") conn.SetProperty("Home", "https://yuque.com/aceld") @@ -63,7 +63,7 @@ func main() { client := znet.NewClient("127.0.0.1", 8999) // Set the business logic to execute when the connection is created or lost - // (添加首次建立链接时的业务) + // (添加首次建立连接时的业务) client.SetOnConnStart(DoClientConnectedBegin) client.SetOnConnStop(DoClientConnectedLost) diff --git a/examples/zinx_decoder/client/client.go b/examples/zinx_decoder/client/client.go index e3297f9d..c0e7f9db 100644 --- a/examples/zinx_decoder/client/client.go +++ b/examples/zinx_decoder/client/client.go @@ -95,7 +95,7 @@ func business(conn ziface.IConnection) { } func DoClientConnectedBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") go business(conn) } diff --git a/examples/zinx_heartbeat/client/client.go b/examples/zinx_heartbeat/client/client.go index 8a36d234..ab7beea0 100644 --- a/examples/zinx_heartbeat/client/client.go +++ b/examples/zinx_heartbeat/client/client.go @@ -17,7 +17,7 @@ func myClientHeartBeatMsg(conn ziface.IConnection) []byte { // 用户自定义的远程连接不存活时的处理方法 func myClientOnRemoteNotAlive(conn ziface.IConnection) { fmt.Println("myClientOnRemoteNotAlive is Called, connID=", conn.GetConnID(), "remoteAddr = ", conn.RemoteAddr()) - //关闭链接 + //关闭连接 conn.Stop() } diff --git a/examples/zinx_heartbeat/server/server.go b/examples/zinx_heartbeat/server/server.go index 5b5123bc..e0a42a12 100644 --- a/examples/zinx_heartbeat/server/server.go +++ b/examples/zinx_heartbeat/server/server.go @@ -17,7 +17,7 @@ func myHeartBeatMsg(conn ziface.IConnection) []byte { // 用户自定义的远程连接不存活时的处理方法 func myOnRemoteNotAlive(conn ziface.IConnection) { fmt.Println("myOnRemoteNotAlive is Called, connID=", conn.GetConnID(), "remoteAddr = ", conn.RemoteAddr()) - //关闭链接 + //关闭连接 conn.Stop() } diff --git a/examples/zinx_logger/client/client.go b/examples/zinx_logger/client/client.go index 3d013e39..32b66215 100644 --- a/examples/zinx_logger/client/client.go +++ b/examples/zinx_logger/client/client.go @@ -26,7 +26,7 @@ func business(conn ziface.IConnection) { } func DoClientConnectedBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") conn.SetProperty("Name", "刘丹冰") conn.SetProperty("Home", "https://yuque.com/aceld") diff --git a/examples/zinx_metrics/client/c1/client.go b/examples/zinx_metrics/client/c1/client.go index 89691290..ebce0a84 100644 --- a/examples/zinx_metrics/client/c1/client.go +++ b/examples/zinx_metrics/client/c1/client.go @@ -26,9 +26,9 @@ func business(conn ziface.IConnection) { } func DoClientConnectedBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") - //设置两个链接属性,在连接创建之后 + //设置两个连接属性,在连接创建之后 conn.SetProperty("Name", "刘丹冰Aceld") conn.SetProperty("Home", "https://yuque.com/aceld") diff --git a/examples/zinx_metrics/client/c2/client.go b/examples/zinx_metrics/client/c2/client.go index 5e95a333..1abf17f7 100644 --- a/examples/zinx_metrics/client/c2/client.go +++ b/examples/zinx_metrics/client/c2/client.go @@ -26,7 +26,7 @@ func business(conn ziface.IConnection) { } func DoClientConnectedBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") conn.SetProperty("Name", "刘丹冰Aceld") conn.SetProperty("Home", "https://yuque.com/aceld") diff --git a/examples/zinx_metrics/server/server.go b/examples/zinx_metrics/server/server.go index 00722e3a..ee4a69a1 100644 --- a/examples/zinx_metrics/server/server.go +++ b/examples/zinx_metrics/server/server.go @@ -8,7 +8,7 @@ import ( ) func DoConnectionBegin(conn ziface.IConnection) { - zlog.Ins().InfoF("DoConnecionBegin is Called ...") + zlog.Ins().InfoF("DoConnectionBegin is Called ...") conn.SetProperty("Name", "Aceld") conn.SetProperty("Home", "https://yuque.com/aceld") diff --git a/examples/zinx_mutiport/client8999/client.go b/examples/zinx_mutiport/client8999/client.go index 89691290..ebce0a84 100644 --- a/examples/zinx_mutiport/client8999/client.go +++ b/examples/zinx_mutiport/client8999/client.go @@ -26,9 +26,9 @@ func business(conn ziface.IConnection) { } func DoClientConnectedBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") - //设置两个链接属性,在连接创建之后 + //设置两个连接属性,在连接创建之后 conn.SetProperty("Name", "刘丹冰Aceld") conn.SetProperty("Home", "https://yuque.com/aceld") diff --git a/examples/zinx_mutiport/client9000/client.go b/examples/zinx_mutiport/client9000/client.go index 707267ed..7d7b2791 100644 --- a/examples/zinx_mutiport/client9000/client.go +++ b/examples/zinx_mutiport/client9000/client.go @@ -26,7 +26,7 @@ func business(conn ziface.IConnection) { } func DoClientConnectedBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") conn.SetProperty("Name", "刘丹冰Aceld") conn.SetProperty("Home", "https://yuque.com/aceld") diff --git a/examples/zinx_mutiport/server/server.go b/examples/zinx_mutiport/server/server.go index 09eee3cc..3e69af08 100644 --- a/examples/zinx_mutiport/server/server.go +++ b/examples/zinx_mutiport/server/server.go @@ -13,9 +13,9 @@ import ( // Execute when creating a connection (创建连接的时候执行) func DoConnectionBegin(conn ziface.IConnection) { - zlog.Ins().InfoF("DoConnecionBegin is Called ...") + zlog.Ins().InfoF("DoConnectionBegin is Called ...") - //设置两个链接属性,在连接创建之后 + //设置两个连接属性,在连接创建之后 conn.SetProperty("Name", "Aceld") conn.SetProperty("Home", "https://yuque.com/@aceld") diff --git a/examples/zinx_server/main.go b/examples/zinx_server/main.go index c986e28f..65ebf888 100644 --- a/examples/zinx_server/main.go +++ b/examples/zinx_server/main.go @@ -16,9 +16,9 @@ import ( // DoConnectionBegin Executed when creating a connection. // 创建连接的时候执行 func DoConnectionBegin(conn ziface.IConnection) { - zlog.Ins().InfoF("DoConnecionBegin is Called ...") + zlog.Ins().InfoF("DoConnectionBegin is Called ...") - //设置两个链接属性,在连接创建之后 + //设置两个连接属性,在连接创建之后 conn.SetProperty("Name", "Aceld") conn.SetProperty("Home", "https://www.kancloud.cn/@aceld") diff --git a/examples/zinx_version_ex/ZinxV0.10Test/server/Server.go b/examples/zinx_version_ex/ZinxV0.10Test/server/Server.go index 47353e7a..34aa2a6b 100644 --- a/examples/zinx_version_ex/ZinxV0.10Test/server/Server.go +++ b/examples/zinx_version_ex/ZinxV0.10Test/server/Server.go @@ -41,9 +41,9 @@ func (this *HelloZinxRouter) Handle(request ziface.IRequest) { // 创建连接的时候执行 func DoConnectionBegin(conn ziface.IConnection) { - fmt.Println("DoConnecionBegin is Called ... ") + fmt.Println("DoConnectionBegin is Called ... ") - //设置两个链接属性,在连接创建之后 + //设置两个连接属性,在连接创建之后 fmt.Println("Set conn Name, Home done!") conn.SetProperty("Name", "Aceld") conn.SetProperty("Home", "https://www.jianshu.com/u/35261429b7f1") @@ -72,7 +72,7 @@ func main() { //创建一个server句柄 s := znet.NewServer() - //注册链接hook回调函数 + //注册连接hook回调函数 s.SetOnConnStart(DoConnectionBegin) s.SetOnConnStop(DoConnectionLost) diff --git a/examples/zinx_version_ex/ZinxV0.11Test/server/Server.go b/examples/zinx_version_ex/ZinxV0.11Test/server/Server.go index eac556c9..971bbc47 100644 --- a/examples/zinx_version_ex/ZinxV0.11Test/server/Server.go +++ b/examples/zinx_version_ex/ZinxV0.11Test/server/Server.go @@ -48,9 +48,9 @@ func (this *HelloZinxRouter) Handle(request ziface.IRequest) { // 创建连接的时候执行 func DoConnectionBegin(conn ziface.IConnection) { - zlog.Debug("DoConnecionBegin is Called ... ") + zlog.Debug("DoConnectionBegin is Called ... ") - //设置两个链接属性,在连接创建之后 + //设置两个连接属性,在连接创建之后 zlog.Debug("Set conn Name, Home done!") conn.SetProperty("Name", "Aceld") conn.SetProperty("Home", "https://www.jianshu.com/u/35261429b7f1") @@ -79,7 +79,7 @@ func main() { //创建一个server句柄 s := znet.NewServer() - //注册链接hook回调函数 + //注册连接hook回调函数 s.SetOnConnStart(DoConnectionBegin) s.SetOnConnStop(DoConnectionLost) diff --git a/examples/zinx_version_ex/ZinxV0.9Test/server/Server.go b/examples/zinx_version_ex/ZinxV0.9Test/server/Server.go index 84771b88..11aa0735 100644 --- a/examples/zinx_version_ex/ZinxV0.9Test/server/Server.go +++ b/examples/zinx_version_ex/ZinxV0.9Test/server/Server.go @@ -41,7 +41,7 @@ func (this *HelloZinxRouter) Handle(request ziface.IRequest) { // 创建连接的时候执行 func DoConnectionBegin(conn ziface.IConnection) { - fmt.Println("DoConnecionBegin is Called ... ") + fmt.Println("DoConnectionBegin is Called ... ") err := conn.SendMsg(2, []byte("DoConnection BEGIN...")) if err != nil { fmt.Println(err) @@ -57,7 +57,7 @@ func main() { //创建一个server句柄 s := znet.NewServer() - //注册链接hook回调函数 + //注册连接hook回调函数 s.SetOnConnStart(DoConnectionBegin) s.SetOnConnStop(DoConnectionLost) diff --git a/examples/zinx_websocket/client/client.go b/examples/zinx_websocket/client/client.go index b7790118..eb647627 100644 --- a/examples/zinx_websocket/client/client.go +++ b/examples/zinx_websocket/client/client.go @@ -34,7 +34,7 @@ func business(conn ziface.IConnection) { // 创建连接的时候执行 func DoClientConnectedBegin(conn ziface.IConnection) { - //设置两个链接属性,在连接创建之后 + //设置两个连接属性,在连接创建之后 conn.SetProperty("Name", "刘丹冰") conn.SetProperty("Home", "https://yuque.com/aceld") @@ -52,7 +52,7 @@ func main() { // Create a Client. client := znet.NewWsClient("127.0.0.1", 9000) - // Add business logic for when the connection is first established.(添加首次建立链接时的业务) + // Add business logic for when the connection is first established.(添加首次建立连接时的业务) client.SetOnConnStart(DoClientConnectedBegin) // Register business routing for receiving messages from the server.(注册收到服务器消息业务路由) client.AddRouter(2, &c_router.PingRouter{}) diff --git a/examples/zinx_websocket/minicode/index/index.js b/examples/zinx_websocket/minicode/index/index.js index 24b4ffe2..b8d7db67 100644 --- a/examples/zinx_websocket/minicode/index/index.js +++ b/examples/zinx_websocket/minicode/index/index.js @@ -5,7 +5,7 @@ Page({ }, onLoad() { - console.log('代码片段是一种迷你、可分享的小程序或小游戏项目,可用于分享小程序和小游戏的开发经验、展示组件和 API 的使用、复现开发问题和 Bug 等。可点击以下链接查看代码片段的详细文档:') + console.log('代码片段是一种迷你、可分享的小程序或小游戏项目,可用于分享小程序和小游戏的开发经验、展示组件和 API 的使用、复现开发问题和 Bug 等。可点击以下连接查看代码片段的详细文档:') console.log('https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/devtools.html') }, }) diff --git a/zasync_op/async_op_result.go b/zasync_op/async_op_result.go index 9753b9b7..27b82843 100644 --- a/zasync_op/async_op_result.go +++ b/zasync_op/async_op_result.go @@ -14,7 +14,7 @@ import ( ) type AsyncOpResult struct { - // Player connection (玩家链接) + // Player connection (玩家连接) conn ziface.IConnection // Returned object (已返回对象) returnedObj interface{} diff --git a/zconf/zconf.go b/zconf/zconf.go index b99a958f..215d41b0 100644 --- a/zconf/zconf.go +++ b/zconf/zconf.go @@ -70,10 +70,10 @@ type Config struct { */ Version string // The version of the Zinx framework.(当前Zinx版本号) MaxPacketSize uint32 // The maximum size of the packets that can be sent or received.(读写数据包的最大值) - MaxConn int // The maximum number of connections that the server can handle.(当前服务器主机允许的最大链接个数) + MaxConn int // The maximum number of connections that the server can handle.(当前服务器主机允许的最大连接个数) WorkerPoolSize uint32 // The number of worker pools in the business logic.(业务工作Worker池的数量) MaxWorkerTaskLen uint32 // The maximum number of tasks that a worker pool can handle.(业务工作Worker对应负责的任务队列最大任务存储数量) - WorkerMode string // The way to assign workers to connections.(为链接分配worker的方式) + WorkerMode string // The way to assign workers to connections.(为连接分配worker的方式) MaxMsgChanLen uint32 // The maximum length of the send buffer message queue.(SendBuffMsg发送消息的缓冲最大长度) IOReadBuffSize uint32 // The maximum size of the read buffer for each IO operation.(每次IO最大的读取长度) diff --git a/ziface/iconnection.go b/ziface/iconnection.go index 00f1c549..aa7ae229 100644 --- a/ziface/iconnection.go +++ b/ziface/iconnection.go @@ -32,8 +32,8 @@ type IConnection interface { GetConnIdStr() string // Get the current connection ID for string (获取当前字符串连接ID) GetMsgHandler() IMsgHandle // Get the message handler (获取消息处理器) GetWorkerID() uint32 // Get Worker ID(获取workerid) - RemoteAddr() net.Addr // Get the remote address information of the connection (获取链接远程地址信息) - LocalAddr() net.Addr // Get the local address information of the connection (获取链接本地地址信息) + RemoteAddr() net.Addr // Get the remote address information of the connection (获取连接远程地址信息) + LocalAddr() net.Addr // Get the local address information of the connection (获取连接本地地址信息) LocalAddrString() string // Get the local address information of the connection as a string RemoteAddrString() string // Get the remote address information of the connection as a string diff --git a/ziface/inotify.go b/ziface/inotify.go index a97a3ab5..aac0b7df 100644 --- a/ziface/inotify.go +++ b/ziface/inotify.go @@ -10,15 +10,15 @@ type Inotify interface { ConnNums() int // Add a connection - // (添加链接) + // (添加连接) SetNotifyID(Id uint64, conn IConnection) // Get a connection by id - // (得到某个链接) + // (得到某个连接) GetNotifyByID(Id uint64) (IConnection, error) // Delete a connection by id - // (删除某个链接) + // (删除某个连接) DelNotifyByID(Id uint64) // Notify a connection with the given id diff --git a/ziface/irequest.go b/ziface/irequest.go index bffa5af2..f77277c9 100644 --- a/ziface/irequest.go +++ b/ziface/irequest.go @@ -12,7 +12,7 @@ type IFuncRequest interface { // IRequest interface: // It actually packages the connection information and request data of the client request into Request -// (实际上是把客户端请求的链接信息 和 请求的数据 包装到了 Request里) +// (实际上是把客户端请求的连接信息 和 请求的数据 包装到了 Request里) type IRequest interface { GetConnection() IConnection // Get the connection information of the request(获取请求连接信息) diff --git a/ziface/irouter.go b/ziface/irouter.go index 0eb0dd4b..fcc7ba28 100644 --- a/ziface/irouter.go +++ b/ziface/irouter.go @@ -7,8 +7,8 @@ package ziface // business method set by the framework user for this connection. The IRequest // in the route includes the connection information and the request data // information for this connection. -// (路由接口, 这里面路由是 使用框架者给该链接自定的 处理业务方法 -// 路由里的IRequest 则包含用该链接的链接信息和该链接的请求数据信息) +// (路由接口, 这里面路由是 使用框架者给该连接自定的 处理业务方法 +// 路由里的IRequest 则包含用该连接的连接信息和该连接的请求数据信息) type IRouter interface { PreHandle(request IRequest) //Hook method before processing conn business(在处理conn业务之前的钩子方法) Handle(request IRequest) //Method for processing conn business(处理conn业务的方法) diff --git a/ziface/iserver.go b/ziface/iserver.go index b5c68e6f..74992271 100644 --- a/ziface/iserver.go +++ b/ziface/iserver.go @@ -15,7 +15,7 @@ type IServer interface { Serve() // Start the business service method(开启业务服务方法) // Routing feature: register a routing business method for the current service for client link processing use - //(路由功能:给当前服务注册一个路由业务方法,供客户端链接处理使用) + //(路由功能:给当前服务注册一个路由业务方法,供客户端连接处理使用) AddRouter(msgID uint32, router IRouter) // New version of routing (新版路由方式) @@ -27,7 +27,7 @@ type IServer interface { // Common component management (公共组件管理) Use(Handlers ...RouterHandler) IRouterSlices - // Get connection management (得到链接管理) + // Get connection management (得到连接管理) GetConnMgr() IConnManager // Set Hook function when the connection is created for the Server (设置该Server的连接创建时Hook函数) diff --git a/znet/client.go b/znet/client.go index 2287d0d2..71f09891 100644 --- a/znet/client.go +++ b/znet/client.go @@ -17,14 +17,14 @@ import ( type Client struct { // Client Name 客户端的名称 Name string - // IP of the target server to connect 目标链接服务器的IP + // IP of the target server to connect 目标连接服务器的IP Ip string - // Port of the target server to connect 目标链接服务器的端口 + // Port of the target server to connect 目标连接服务器的端口 Port int Url *url.URL // 扩展,连接时带上其他参数 // Client version tcp,websocket,客户端版本 tcp,websocket version string - // Connection instance 链接实例 + // Connection instance 连接实例 conn ziface.IConnection // Hook function called on connection start 该client的连接创建时Hook函数 onConnStart func(conn ziface.IConnection) @@ -32,7 +32,7 @@ type Client struct { onConnStop func(conn ziface.IConnection) // Data packet packer 数据报文封包方式 packet ziface.IDataPack - // Asynchronous channel for capturing connection close status 异步捕获链接关闭状态 + // Asynchronous channel for capturing connection close status 异步捕获连接关闭状态 exitChan chan struct{} // Message management module 消息管理模块 msgHandler ziface.IMsgHandle @@ -173,7 +173,7 @@ func (c *Client) Restart() { // HeartBeat detection if c.hc != nil { // Bind connection and heartbeat detector after connection is successfully established - // (创建链接成功,绑定链接与心跳检测器) + // (创建连接成功,绑定连接与心跳检测器) c.hc.BindConn(c.conn) } @@ -188,7 +188,7 @@ func (c *Client) Restart() { } // Start starts the client, sends requests and establishes a connection. -// (启动客户端,发送请求且建立链接) +// (启动客户端,发送请求且建立连接) func (c *Client) Start() { // Add the decoder to the interceptor list (将解码器添加到拦截器) diff --git a/znet/connection.go b/znet/connection.go index 86b66664..4973bea1 100644 --- a/znet/connection.go +++ b/znet/connection.go @@ -43,7 +43,7 @@ type Connection struct { connIdStr string // The workerid responsible for handling the link - // 负责处理该链接的workerid + // 负责处理该连接的workerid workerID uint32 // The message management module that manages MsgID and the corresponding processing method @@ -51,7 +51,7 @@ type Connection struct { msgHandler ziface.IMsgHandle // Channel to notify that the connection has exited/stopped - // (告知该链接已经退出/停止的channel) + // (告知该连接已经退出/停止的channel) ctx context.Context cancel context.CancelFunc @@ -64,7 +64,7 @@ type Connection struct { startWriterFlag int32 // Connection properties - // (链接属性) + // (连接属性) property map[string]interface{} // Lock to protect the current property @@ -72,7 +72,7 @@ type Connection struct { propertyLock sync.Mutex // Which Connection Manager the current connection belongs to - // (当前链接是属于哪个Connection Manager的) + // (当前连接是属于哪个Connection Manager的) connManager ziface.IConnManager // Hook function when the current connection is created @@ -100,15 +100,15 @@ type Connection struct { hc ziface.IHeartbeatChecker // Connection name, default to be the same as the name of the Server/Client that created the connection - // (链接名称,默认与创建链接的Server/Client的Name一致) + // (连接名称,默认与创建连接的Server/Client的Name一致) name string // Local address of the current connection - // (当前链接的本地地址) + // (当前连接的本地地址) localAddr string // Remote address of the current connection - // (当前链接的远程地址) + // (当前连接的远程地址) remoteAddr string // Close callback @@ -152,7 +152,7 @@ func newServerConn(server ziface.IServer, conn net.Conn, connID uint64) ziface.I c.connManager = server.GetConnMgr() // Add the newly created Conn to the connection manager - // (将新创建的Conn添加到链接管理中) + // (将新创建的Conn添加到连接管理中) server.GetConnMgr().Add(c) return c @@ -497,7 +497,7 @@ func (c *Connection) Context() context.Context { func (c *Connection) finalizer() { // Call the callback function registered by the user when closing the connection if it exists - // (如果用户注册了该链接的 关闭回调业务,那么在此刻应该显示调用) + // (如果用户注册了该连接的 关闭回调业务,那么在此刻应该显示调用) c.callOnConnStop() // Stop the heartbeat detector associated with the connection diff --git a/znet/heartbeat.go b/znet/heartbeat.go index 9a78a298..b625b607 100644 --- a/znet/heartbeat.go +++ b/znet/heartbeat.go @@ -19,7 +19,7 @@ type HeartbeatChecker struct { msgID uint32 // Heartbeat message ID(心跳的消息ID) router ziface.IRouter // User-defined heartbeat message business processing router(用户自定义的心跳检测消息业务处理路由) routerSlices []ziface.RouterHandler //(用户自定义的心跳检测消息业务处理新路由) - conn ziface.IConnection // Bound connection(绑定的链接) + conn ziface.IConnection // Bound connection(绑定的连接) beatFunc ziface.HeartBeatFunc // // User-defined heartbeat sending function(用户自定义心跳发送函数) } @@ -162,7 +162,7 @@ func (h *HeartbeatChecker) BindConn(conn ziface.IConnection) { } // Clone clones to a specified connection -// (克隆到一个指定的链接上) +// (克隆到一个指定的连接上) func (h *HeartbeatChecker) Clone() ziface.IHeartbeatChecker { heartbeat := &HeartbeatChecker{ diff --git a/znet/kcp_connection.go b/znet/kcp_connection.go index efdf47c9..e42183ec 100644 --- a/znet/kcp_connection.go +++ b/znet/kcp_connection.go @@ -40,7 +40,7 @@ type KcpConnection struct { connIdStr string // The workerid responsible for handling the link - // 负责处理该链接的workerid + // 负责处理该连接的workerid workerID uint32 // The message management module that manages MsgID and the corresponding processing method @@ -48,7 +48,7 @@ type KcpConnection struct { msgHandler ziface.IMsgHandle // Channel to notify that the connection has exited/stopped - // (告知该链接已经退出/停止的channel) + // (告知该连接已经退出/停止的channel) ctx context.Context cancel context.CancelFunc @@ -61,7 +61,7 @@ type KcpConnection struct { msgLock sync.RWMutex // Connection properties - // (链接属性) + // (连接属性) property map[string]interface{} // Lock to protect the current property @@ -73,7 +73,7 @@ type KcpConnection struct { closed int32 // Which Connection Manager the current connection belongs to - // (当前链接是属于哪个Connection Manager的) + // (当前连接是属于哪个Connection Manager的) connManager ziface.IConnManager // Hook function when the current connection is created @@ -101,15 +101,15 @@ type KcpConnection struct { hc ziface.IHeartbeatChecker // Connection name, default to be the same as the name of the Server/Client that created the connection - // (链接名称,默认与创建链接的Server/Client的Name一致) + // (连接名称,默认与创建连接的Server/Client的Name一致) name string // Local address of the current connection - // (当前链接的本地地址) + // (当前连接的本地地址) localAddr string // Remote address of the current connection - // (当前链接的远程地址) + // (当前连接的远程地址) remoteAddr string // Close callback @@ -150,7 +150,7 @@ func newKcpServerConn(server ziface.IServer, conn *kcp.UDPSession, connID uint64 c.connManager = server.GetConnMgr() // Add the newly created Conn to the connection manager - // (将新创建的Conn添加到链接管理中) + // (将新创建的Conn添加到连接管理中) server.GetConnMgr().Add(c) return c @@ -495,7 +495,7 @@ func (c *KcpConnection) finalizer() { } // Call the callback function registered by the user when closing the connection if it exists - //(如果用户注册了该链接的 关闭回调业务,那么在此刻应该显示调用) + //(如果用户注册了该连接的 关闭回调业务,那么在此刻应该显示调用) c.callOnConnStop() c.msgLock.Lock() diff --git a/znet/msghandler.go b/znet/msghandler.go index b08adecc..9d11558a 100644 --- a/znet/msghandler.go +++ b/znet/msghandler.go @@ -58,7 +58,7 @@ func newMsgHandle() *MsgHandle { if zconf.GlobalObject.WorkerMode == zconf.WorkerModeBind { // Assign a workder to each link, avoid interactions when multiple links are processed by the same worker // MaxWorkerTaskLen can also be reduced, for example, 50 - // 为每个链接分配一个workder,避免同一worker处理多个链接时的互相影响 + // 为每个连接分配一个workder,避免同一worker处理多个连接时的互相影响 // 同时可以减小MaxWorkerTaskLen,比如50,因为每个worker的负担减轻了 zconf.GlobalObject.WorkerPoolSize = uint32(zconf.GlobalObject.MaxConn) freeWorkers = make(map[uint32]struct{}, zconf.GlobalObject.WorkerPoolSize) @@ -112,7 +112,7 @@ func newCliMsgHandle() *MsgHandle { if zconf.GlobalObject.WorkerMode == zconf.WorkerModeBind { // Assign a workder to each link, avoid interactions when multiple links are processed by the same worker // MaxWorkerTaskLen can also be reduced, for example, 50 - // 为每个链接分配一个workder,避免同一worker处理多个链接时的互相影响 + // 为每个连接分配一个workder,避免同一worker处理多个连接时的互相影响 // 同时可以减小MaxWorkerTaskLen,比如50,因为每个worker的负担减轻了 zconf.GlobalObject.WorkerPoolSize = uint32(zconf.GlobalObject.MaxConn) freeWorkers = make(map[uint32]struct{}, zconf.GlobalObject.WorkerPoolSize) diff --git a/znet/request.go b/znet/request.go index 52c4684c..6b6e4745 100644 --- a/znet/request.go +++ b/znet/request.go @@ -28,7 +28,7 @@ func init() { // Request 请求 type Request struct { ziface.BaseRequest - conn ziface.IConnection // the connection which has been established with the client(已经和客户端建立好的链接) + conn ziface.IConnection // the connection which has been established with the client(已经和客户端建立好的连接) msg ziface.IMessage // the request data sent by the client(客户端请求的数据) router ziface.IRouter // the router that handles this request(请求处理的函数) steps ziface.HandleStep // used to control the execution of router functions(用来控制路由函数执行) diff --git a/znet/server.go b/znet/server.go index 2d0e922c..bbfdea6f 100644 --- a/znet/server.go +++ b/znet/server.go @@ -50,7 +50,7 @@ type Server struct { RouterSlicesMode bool // Request 对象池模式 RequestPoolMode bool - // Current server's connection manager (当前Server的链接管理器) + // Current server's connection manager (当前Server的连接管理器) ConnMgr ziface.IConnManager // Hook function called when a new connection is established @@ -66,7 +66,7 @@ type Server struct { packet ziface.IDataPack // Asynchronous capture of connection closing status - // (异步捕获链接关闭状态) + // (异步捕获连接关闭状态) exitChan chan struct{} // Decoder for dealing with message fragmentation and reassembly diff --git a/znet/ws_connection.go b/znet/ws_connection.go index 9f57532b..12babfbb 100644 --- a/znet/ws_connection.go +++ b/znet/ws_connection.go @@ -40,7 +40,7 @@ type WsConnection struct { connIdStr string // The workerid responsible for handling the link - // 负责处理该链接的workerid + // 负责处理该连接的workerid workerID uint32 // msgHandler is the message management module for MsgID and the corresponding message handling method. @@ -48,7 +48,7 @@ type WsConnection struct { msgHandler ziface.IMsgHandle // ctx and cancel are used to notify that the connection has exited/stopped. - // (告知该链接已经退出/停止的channel) + // (告知该连接已经退出/停止的channel) ctx context.Context cancel context.CancelFunc @@ -60,7 +60,7 @@ type WsConnection struct { // (用户收发消息的Lock) msgLock sync.Mutex - // property is the connection attribute. (链接属性) + // property is the connection attribute. (连接属性) property map[string]interface{} // propertyLock protects the current property lock. (保护当前property的锁) @@ -69,7 +69,7 @@ type WsConnection struct { // isClosed is the current connection's closed state. (当前连接的关闭状态) isClosed bool - // connManager is the Connection Manager to which the current connection belongs. (当前链接是属于哪个Connection Manager的) + // connManager is the Connection Manager to which the current connection belongs. (当前连接是属于哪个Connection Manager的) connManager ziface.IConnManager // onConnStart is the Hook function when the current connection is created. @@ -96,13 +96,13 @@ type WsConnection struct { hc ziface.IHeartbeatChecker // name is the name of the connection and is the same as the Name of the Server/Client that created the connection. - // (链接名称,默认与创建链接的Server/Client的Name一致) + // (连接名称,默认与创建连接的Server/Client的Name一致) name string - // localAddr is the local address of the current connection. (当前链接的本地地址) + // localAddr is the local address of the current connection. (当前连接的本地地址) localAddr string - // remoteAddr is the remote address of the current connection. (当前链接的远程地址) + // remoteAddr is the remote address of the current connection. (当前连接的远程地址) remoteAddr string // Close callback @@ -145,7 +145,7 @@ func newWebsocketConn(server ziface.IServer, conn *websocket.Conn, connID uint64 // Bind the current Connection to the Server's ConnManager (将当前的Connection与Server的ConnManager绑定) c.connManager = server.GetConnMgr() - // Add the newly created Conn to the connection management (将新创建的Conn添加到链接管理中) + // Add the newly created Conn to the connection management (将新创建的Conn添加到连接管理中) server.GetConnMgr().Add(c) return c @@ -496,36 +496,36 @@ func (c *WsConnection) Context() context.Context { func (c *WsConnection) finalizer() { // If the user has registered a close callback for the connection, it should be called explicitly at this moment. - // (如果用户注册了该链接的 关闭回调业务,那么在此刻应该显示调用) + // (如果用户注册了该连接的 关闭回调业务,那么在此刻应该显示调用) c.callOnConnStop() c.msgLock.Lock() defer c.msgLock.Unlock() // If the current connection is already closed. - // (如果当前链接已经关闭) + // (如果当前连接已经关闭) if c.isClosed == true { return } // Stop the heartbeat detector bound to the connection. - // (关闭链接绑定的心跳检测器) + // (关闭连接绑定的心跳检测器) if c.hc != nil { c.hc.Stop() } // Close the socket connection. - // (关闭socket链接) + // (关闭socket连接) _ = c.conn.Close() // Remove the connection from the connection manager. - // (将链接从连接管理器中删除) + // (将连接从连接管理器中删除) if c.connManager != nil { c.connManager.Remove(c) } // Close all channels associated with this connection. - // (关闭该链接全部管道) + // (关闭该连接全部管道) if c.msgBuffChan != nil { close(c.msgBuffChan) } diff --git a/znotify/notify_test.go b/znotify/notify_test.go index 0eaf1f7d..8c154e8e 100644 --- a/znotify/notify_test.go +++ b/znotify/notify_test.go @@ -52,7 +52,7 @@ func Clinet() { return } defer conn.Close() - //链接调用write方法写入数据 + //连接调用write方法写入数据 id := strconv.Itoa(i) dp := zpack.NewDataPack() msg, err := dp.Pack(zpack.NewMsgPackage(1, []byte(id)))