Skip to content

Commit

Permalink
Merge pull request #359 from gongxuanzhang/master
Browse files Browse the repository at this point in the history
fix typo
  • Loading branch information
aceld authored Dec 27, 2024
2 parents 9f12ff3 + bb78fb0 commit fbabb59
Show file tree
Hide file tree
Showing 35 changed files with 95 additions and 95 deletions.
8 changes: 4 additions & 4 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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源码地址
Expand Down Expand Up @@ -52,7 +52,7 @@ http://zinx.me

## 一、写在前面

我们为什么要做Zinx,Golang目前在服务器的应用框架很多,但是应用在游戏领域或者其他长链接的领域的轻量级企业框架甚少
我们为什么要做Zinx,Golang目前在服务器的应用框架很多,但是应用在游戏领域或者其他长连接的领域的轻量级企业框架甚少

设计Zinx的目的是我们可以通过Zinx框架来了解基于Golang编写一个TCP服务器的整体轮廓,让更多的Golang爱好者能深入浅出的去学习和认识这个领域。

Expand Down Expand Up @@ -216,7 +216,7 @@ func main() {
//创建Client客户端
client := znet.NewClient("127.0.0.1", 8999)

//设置链接建立成功后的钩子函数
//设置连接建立成功后的钩子函数
client.SetOnConnStart(onClientStart)

//启动客户端
Expand Down Expand Up @@ -270,7 +270,7 @@ recv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]

`TcpPort`:服务器监听端口

`MaxConn`:允许的客户端链接最大数量
`MaxConn`:允许的客户端连接最大数量

`WorkerPoolSize`:工作任务池最大工作Goroutine数量

Expand Down
6 changes: 3 additions & 3 deletions examples/zinx_RequestPollMode/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions examples/zinx_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion examples/zinx_decoder/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/zinx_heartbeat/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/zinx_heartbeat/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/zinx_logger/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions examples/zinx_metrics/client/c1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion examples/zinx_metrics/client/c2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion examples/zinx_metrics/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions examples/zinx_mutiport/client8999/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion examples/zinx_mutiport/client9000/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions examples/zinx_mutiport/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions examples/zinx_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
6 changes: 3 additions & 3 deletions examples/zinx_version_ex/ZinxV0.10Test/server/Server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -72,7 +72,7 @@ func main() {
//创建一个server句柄
s := znet.NewServer()

//注册链接hook回调函数
//注册连接hook回调函数
s.SetOnConnStart(DoConnectionBegin)
s.SetOnConnStop(DoConnectionLost)

Expand Down
6 changes: 3 additions & 3 deletions examples/zinx_version_ex/ZinxV0.11Test/server/Server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -79,7 +79,7 @@ func main() {
//创建一个server句柄
s := znet.NewServer()

//注册链接hook回调函数
//注册连接hook回调函数
s.SetOnConnStart(DoConnectionBegin)
s.SetOnConnStop(DoConnectionLost)

Expand Down
4 changes: 2 additions & 2 deletions examples/zinx_version_ex/ZinxV0.9Test/server/Server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -57,7 +57,7 @@ func main() {
//创建一个server句柄
s := znet.NewServer()

//注册链接hook回调函数
//注册连接hook回调函数
s.SetOnConnStart(DoConnectionBegin)
s.SetOnConnStop(DoConnectionLost)

Expand Down
4 changes: 2 additions & 2 deletions examples/zinx_websocket/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func business(conn ziface.IConnection) {

// 创建连接的时候执行
func DoClientConnectedBegin(conn ziface.IConnection) {
//设置两个链接属性,在连接创建之后
//设置两个连接属性,在连接创建之后
conn.SetProperty("Name", "刘丹冰")
conn.SetProperty("Home", "https://yuque.com/aceld")

Expand All @@ -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{})
Expand Down
2 changes: 1 addition & 1 deletion examples/zinx_websocket/minicode/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
},
})
2 changes: 1 addition & 1 deletion zasync_op/async_op_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

type AsyncOpResult struct {
// Player connection (玩家链接)
// Player connection (玩家连接)
conn ziface.IConnection
// Returned object (已返回对象)
returnedObj interface{}
Expand Down
4 changes: 2 additions & 2 deletions zconf/zconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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最大的读取长度)

Expand Down
4 changes: 2 additions & 2 deletions ziface/iconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions ziface/inotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ziface/irequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(获取请求连接信息)

Expand Down
4 changes: 2 additions & 2 deletions ziface/irouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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业务的方法)
Expand Down
4 changes: 2 additions & 2 deletions ziface/iserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (新版路由方式)
Expand All @@ -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函数)
Expand Down
Loading

0 comments on commit fbabb59

Please sign in to comment.