Browse Source

zinx tcp库 改到本地

master
zhipeng.hu 3 years ago
parent
commit
dd4e34052e
  1. 14
      README.md
  2. 2
      examples/zinx_client/main.go
  3. 9
      examples/zinx_server/main.go
  4. 7
      examples/zinx_server/zrouter/hello.go
  5. 6
      examples/zinx_server/zrouter/ping.go
  6. 2
      examples/zinx_version_ex/ZinxV0.10Test/Client0.go
  7. 2
      examples/zinx_version_ex/ZinxV0.10Test/Client1.go
  8. 4
      examples/zinx_version_ex/ZinxV0.10Test/Server.go
  9. 2
      examples/zinx_version_ex/ZinxV0.11Test/Client0.go
  10. 2
      examples/zinx_version_ex/ZinxV0.11Test/Client1.go
  11. 6
      examples/zinx_version_ex/ZinxV0.11Test/Server.go
  12. 2
      examples/zinx_version_ex/ZinxV0.1Test/Server.go
  13. 2
      examples/zinx_version_ex/ZinxV0.2Test/Server.go
  14. 4
      examples/zinx_version_ex/ZinxV0.3Test/Server.go
  15. 4
      examples/zinx_version_ex/ZinxV0.4Test/Server.go
  16. 2
      examples/zinx_version_ex/ZinxV0.5Test/Client.go
  17. 4
      examples/zinx_version_ex/ZinxV0.5Test/Server.go
  18. 2
      examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Client0.go
  19. 2
      examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Client1.go
  20. 4
      examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Server.go
  21. 2
      examples/zinx_version_ex/ZinxV0.8Test/Client0.go
  22. 2
      examples/zinx_version_ex/ZinxV0.8Test/Client1.go
  23. 4
      examples/zinx_version_ex/ZinxV0.8Test/Server.go
  24. 2
      examples/zinx_version_ex/ZinxV0.9Test/Client0.go
  25. 2
      examples/zinx_version_ex/ZinxV0.9Test/Client1.go
  26. 4
      examples/zinx_version_ex/ZinxV0.9Test/Server.go
  27. 2
      examples/zinx_version_ex/datapackDemo/Client.go
  28. 2
      examples/zinx_version_ex/datapackDemo/Server.go
  29. 2
      examples/zinx_version_ex/protoDemo/main.go
  30. 2
      go.mod
  31. 4
      utils/globalobj.go
  32. 8
      zinx_app_demo/mmo_game/api/move.go
  33. 8
      zinx_app_demo/mmo_game/api/world_chat.go
  34. 2
      zinx_app_demo/mmo_game/client_AI_robot.go
  35. 4
      zinx_app_demo/mmo_game/core/player.go
  36. 8
      zinx_app_demo/mmo_game/server.go
  37. 2
      zlog/zlogger_test.go
  38. 4
      znet/connection.go
  39. 2
      znet/connmanager.go
  40. 4
      znet/datapack.go
  41. 4
      znet/msghandler.go
  42. 2
      znet/options.go
  43. 2
      znet/request.go
  44. 2
      znet/router.go
  45. 4
      znet/server.go
  46. 2
      znet/server_test.go
  47. 2
      ztimer/delayfunc.go
  48. 2
      ztimer/timerscheduler.go
  49. 2
      ztimer/timerscheduler_test.go
  50. 2
      ztimer/timewheel.go

14
README.md

@ -10,7 +10,7 @@ Zinx 是一个基于Golang的轻量级并发服务器框架
--- ---
## zinx源码地址 ## zinx源码地址
### Github ### Github
Git: https://github.com/aceld/zinx
Git: https://zinx
### 码云(Gitee) ### 码云(Gitee)
Git: https://gitee.com/Aceld/zinx Git: https://gitee.com/Aceld/zinx
@ -68,7 +68,7 @@ Zinx框架的项目制作采用编码和学习教程同步进行,将开发的
```bash ```bash
# 克隆项目 # 克隆项目
$ git clone https://github.com/aceld/zinx.git
$ git clone https://zinx.git
# 进入服务端样例目录 # 进入服务端样例目录
$ cd ./zinx/examples/zinx_server $ cd ./zinx/examples/zinx_server
@ -179,8 +179,8 @@ func main() {
```go ```go
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由
@ -211,7 +211,7 @@ import (
"io" "io"
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*
@ -398,7 +398,7 @@ func (c *Connection) RemoveProperty(key string)
- 胡琪([@huqitt](https://github.com/huqitt)) - 胡琪([@huqitt](https://github.com/huqitt))
--- ---
[zinx(websocket版本)](https://github.com/aceld/zinx/tree/wsserver)
[zinx(websocket版本)](https://zinx/tree/wsserver)
#### 开发者 #### 开发者
- 胡贵建([@huguijian](https://github.com/huguijian)) - 胡贵建([@huguijian](https://github.com/huguijian))
@ -407,7 +407,7 @@ func (c *Connection) RemoveProperty(key string)
感谢所有为zinx贡献的开发者 感谢所有为zinx贡献的开发者
<a href="https://github.com/aceld/zinx/graphs/contributors">
<a href="https://zinx/graphs/contributors">
<img src="https://contrib.rocks/image?repo=aceld/zinx" /> <img src="https://contrib.rocks/image?repo=aceld/zinx" />
</a> </a>

2
examples/zinx_client/main.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

9
examples/zinx_server/main.go

@ -7,13 +7,12 @@
package main package main
import ( import (
"github.com/aceld/zinx/examples/zinx_server/zrouter"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zlog"
"github.com/aceld/zinx/znet"
"zinx/examples/zinx_server/zrouter"
"zinx/ziface"
"zinx/zlog"
"zinx/znet"
) )
//创建连接的时候执行 //创建连接的时候执行
func DoConnectionBegin(conn ziface.IConnection) { func DoConnectionBegin(conn ziface.IConnection) {
zlog.Debug("DoConnecionBegin is Called ... ") zlog.Debug("DoConnecionBegin is Called ... ")

7
examples/zinx_server/zrouter/hello.go

@ -1,9 +1,9 @@
package zrouter package zrouter
import ( import (
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zlog"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/zlog"
"zinx/znet"
) )
type HelloZinxRouter struct { type HelloZinxRouter struct {
@ -21,4 +21,3 @@ func (this *HelloZinxRouter) Handle(request ziface.IRequest) {
zlog.Error(err) zlog.Error(err)
} }
} }

6
examples/zinx_server/zrouter/ping.go

@ -1,9 +1,9 @@
package zrouter package zrouter
import ( import (
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zlog"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/zlog"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

2
examples/zinx_version_ex/ZinxV0.10Test/Client0.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

2
examples/zinx_version_ex/ZinxV0.10Test/Client1.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

4
examples/zinx_version_ex/ZinxV0.10Test/Server.go

@ -2,8 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

2
examples/zinx_version_ex/ZinxV0.11Test/Client0.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

2
examples/zinx_version_ex/ZinxV0.11Test/Client1.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

6
examples/zinx_version_ex/ZinxV0.11Test/Server.go

@ -7,9 +7,9 @@
package main package main
import ( import (
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zlog"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/zlog"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

2
examples/zinx_version_ex/ZinxV0.1Test/Server.go

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
//Server 模块的测试函数 //Server 模块的测试函数

2
examples/zinx_version_ex/ZinxV0.2Test/Server.go

@ -1,7 +1,7 @@
package main package main
import ( import (
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
//Server 模块的测试函数 //Server 模块的测试函数

4
examples/zinx_version_ex/ZinxV0.3Test/Server.go

@ -3,8 +3,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

4
examples/zinx_version_ex/ZinxV0.4Test/Server.go

@ -3,8 +3,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

2
examples/zinx_version_ex/ZinxV0.5Test/Client.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

4
examples/zinx_version_ex/ZinxV0.5Test/Server.go

@ -3,8 +3,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

2
examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Client0.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

2
examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Client1.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

4
examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Server.go

@ -2,8 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

2
examples/zinx_version_ex/ZinxV0.8Test/Client0.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

2
examples/zinx_version_ex/ZinxV0.8Test/Client1.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

4
examples/zinx_version_ex/ZinxV0.8Test/Server.go

@ -2,8 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

2
examples/zinx_version_ex/ZinxV0.9Test/Client0.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

2
examples/zinx_version_ex/ZinxV0.9Test/Client1.go

@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
/* /*

4
examples/zinx_version_ex/ZinxV0.9Test/Server.go

@ -2,8 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/znet"
) )
//ping test 自定义路由 //ping test 自定义路由

2
examples/zinx_version_ex/datapackDemo/Client.go

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
func main() { func main() {

2
examples/zinx_version_ex/datapackDemo/Server.go

@ -5,7 +5,7 @@ import (
"io" "io"
"net" "net"
"github.com/aceld/zinx/znet"
"zinx/znet"
) )
//只是负责测试datapack拆包,封包功能 //只是负责测试datapack拆包,封包功能

2
examples/zinx_version_ex/protoDemo/main.go

@ -2,8 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/examples/zinx_version_ex/protoDemo/pb"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"zinx/examples/zinx_version_ex/protoDemo/pb"
) )
func main() { func main() {

2
go.mod

@ -1,4 +1,4 @@
module github.com/aceld/zinx
module zinx
go 1.13 go 1.13

4
utils/globalobj.go

@ -14,8 +14,8 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zlog"
"zinx/ziface"
"zinx/zlog"
) )
/* /*

8
zinx_app_demo/mmo_game/api/move.go

@ -3,11 +3,11 @@ package api
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zinx_app_demo/mmo_game/core"
"github.com/aceld/zinx/zinx_app_demo/mmo_game/pb"
"github.com/aceld/zinx/znet"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"zinx/ziface"
"zinx/zinx_app_demo/mmo_game/core"
"zinx/zinx_app_demo/mmo_game/pb"
"zinx/znet"
) )
//玩家移动 //玩家移动

8
zinx_app_demo/mmo_game/api/world_chat.go

@ -3,11 +3,11 @@ package api
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zinx_app_demo/mmo_game/core"
"github.com/aceld/zinx/zinx_app_demo/mmo_game/pb"
"github.com/aceld/zinx/znet"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"zinx/ziface"
"zinx/zinx_app_demo/mmo_game/core"
"zinx/zinx_app_demo/mmo_game/pb"
"zinx/znet"
) )
//世界聊天 路由业务 //世界聊天 路由业务

2
zinx_app_demo/mmo_game/client_AI_robot.go

@ -11,8 +11,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/aceld/zinx/zinx_app_demo/mmo_game/pb"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"zinx/zinx_app_demo/mmo_game/pb"
) )
type Message struct { type Message struct {

4
zinx_app_demo/mmo_game/core/player.go

@ -6,9 +6,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zinx_app_demo/mmo_game/pb"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"zinx/ziface"
"zinx/zinx_app_demo/mmo_game/pb"
) )
//玩家对象 //玩家对象

8
zinx_app_demo/mmo_game/server.go

@ -3,10 +3,10 @@ package main
import ( import (
"fmt" "fmt"
"github.com/aceld/zinx/ziface"
"github.com/aceld/zinx/zinx_app_demo/mmo_game/api"
"github.com/aceld/zinx/zinx_app_demo/mmo_game/core"
"github.com/aceld/zinx/znet"
"zinx/ziface"
"zinx/zinx_app_demo/mmo_game/api"
"zinx/zinx_app_demo/mmo_game/core"
"zinx/znet"
) )
//当客户端建立连接的时候的hook函数 //当客户端建立连接的时候的hook函数

2
zlog/zlogger_test.go

@ -1,8 +1,8 @@
package zlog_test package zlog_test
import ( import (
"github.com/aceld/zinx/zlog"
"testing" "testing"
"zinx/zlog"
) )
func TestStdZLog(t *testing.T) { func TestStdZLog(t *testing.T) {

4
znet/connection.go

@ -8,8 +8,8 @@ import (
"net" "net"
"sync" "sync"
"github.com/aceld/zinx/utils"
"github.com/aceld/zinx/ziface"
"zinx/utils"
"zinx/ziface"
) )
//Connection 链接 //Connection 链接

2
znet/connmanager.go

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/aceld/zinx/ziface"
"zinx/ziface"
) )
//ConnManager 连接管理模块 //ConnManager 连接管理模块

4
znet/datapack.go

@ -5,8 +5,8 @@ import (
"encoding/binary" "encoding/binary"
"errors" "errors"
"github.com/aceld/zinx/utils"
"github.com/aceld/zinx/ziface"
"zinx/utils"
"zinx/ziface"
) )
var defaultHeaderLen uint32 = 8 var defaultHeaderLen uint32 = 8

4
znet/msghandler.go

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"github.com/aceld/zinx/utils"
"github.com/aceld/zinx/ziface"
"zinx/utils"
"zinx/ziface"
) )
// MsgHandle - // MsgHandle -

2
znet/options.go

@ -1,6 +1,6 @@
package znet package znet
import "github.com/aceld/zinx/ziface"
import "zinx/ziface"
type Option func(s *Server) type Option func(s *Server)

2
znet/request.go

@ -1,6 +1,6 @@
package znet package znet
import "github.com/aceld/zinx/ziface"
import "zinx/ziface"
//Request 请求 //Request 请求
type Request struct { type Request struct {

2
znet/router.go

@ -1,6 +1,6 @@
package znet package znet
import "github.com/aceld/zinx/ziface"
import "zinx/ziface"
//BaseRouter 实现router时,先嵌入这个基类,然后根据需要对这个基类的方法进行重写 //BaseRouter 实现router时,先嵌入这个基类,然后根据需要对这个基类的方法进行重写
type BaseRouter struct{} type BaseRouter struct{}

4
znet/server.go

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/aceld/zinx/utils"
"github.com/aceld/zinx/ziface"
"zinx/utils"
"zinx/ziface"
) )
var zinxLogo = ` var zinxLogo = `

2
znet/server_test.go

@ -7,7 +7,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/aceld/zinx/ziface"
"zinx/ziface"
) )
// run in terminal: // run in terminal:

2
ztimer/delayfunc.go

@ -9,7 +9,7 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"github.com/aceld/zinx/zlog"
"zinx/zlog"
) )
/* /*

2
ztimer/timerscheduler.go

@ -14,7 +14,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/aceld/zinx/zlog"
"zinx/zlog"
) )
const ( const (

2
ztimer/timerscheduler_test.go

@ -14,7 +14,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/aceld/zinx/zlog"
"zinx/zlog"
) )
//触发函数 //触发函数

2
ztimer/timewheel.go

@ -12,7 +12,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/aceld/zinx/zlog"
"zinx/zlog"
) )
/* /*

Loading…
Cancel
Save