Browse Source
Merge pull request #48 from adsian/refactor
replace zinx with github.com/aceld/zinx
master
Gao Zhihui
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with
70 additions and
70 deletions
-
README.md
-
examples/zinx_version_ex/ZinxV0.10Test/Client0.go
-
examples/zinx_version_ex/ZinxV0.10Test/Client1.go
-
examples/zinx_version_ex/ZinxV0.10Test/Server.go
-
examples/zinx_version_ex/ZinxV0.11Test/Client0.go
-
examples/zinx_version_ex/ZinxV0.11Test/Client1.go
-
examples/zinx_version_ex/ZinxV0.11Test/Server.go
-
examples/zinx_version_ex/ZinxV0.1Test/Server.go
-
examples/zinx_version_ex/ZinxV0.2Test/Server.go
-
examples/zinx_version_ex/ZinxV0.3Test/Server.go
-
examples/zinx_version_ex/ZinxV0.4Test/Server.go
-
examples/zinx_version_ex/ZinxV0.5Test/Client.go
-
examples/zinx_version_ex/ZinxV0.5Test/Server.go
-
examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Client0.go
-
examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Client1.go
-
examples/zinx_version_ex/ZinxV0.6Test-V0.7Test/Server.go
-
examples/zinx_version_ex/ZinxV0.8Test/Client0.go
-
examples/zinx_version_ex/ZinxV0.8Test/Client1.go
-
examples/zinx_version_ex/ZinxV0.8Test/Server.go
-
examples/zinx_version_ex/ZinxV0.9Test/Client0.go
-
examples/zinx_version_ex/ZinxV0.9Test/Client1.go
-
examples/zinx_version_ex/ZinxV0.9Test/Server.go
-
examples/zinx_version_ex/datapackDemo/Client.go
-
examples/zinx_version_ex/datapackDemo/Server.go
-
examples/zinx_version_ex/protoDemo/main.go
-
go.mod
-
utils/globalobj.go
-
zinx_app_demo/mmo_game/api/move.go
-
zinx_app_demo/mmo_game/api/world_chat.go
-
zinx_app_demo/mmo_game/client_AI_robot.go
-
zinx_app_demo/mmo_game/core/player.go
-
zinx_app_demo/mmo_game/server.go
-
znet/connection.go
-
znet/connmanager.go
-
znet/datapack.go
-
znet/msghandler.go
-
znet/request.go
-
znet/router.go
-
znet/server.go
-
znet/server_test.go
-
ztimer/delayfunc.go
-
ztimer/timerscheduler.go
-
ztimer/timerscheduler_test.go
-
ztimer/timewheel.go
|
|
@ -101,8 +101,8 @@ func main() { |
|
|
|
```go |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由 |
|
|
@ -133,7 +133,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -2,8 +2,8 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由
|
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -7,9 +7,9 @@ |
|
|
|
package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/zlog" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/zlog" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由
|
|
|
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2,8 +2,8 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由
|
|
|
|
|
|
@ -2,8 +2,8 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由
|
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -2,8 +2,8 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由
|
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -2,8 +2,8 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由
|
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -2,8 +2,8 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由
|
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -2,8 +2,8 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//ping test 自定义路由
|
|
|
|
|
|
@ -3,7 +3,7 @@ package main |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"net" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
func main() { |
|
|
|
|
|
@ -4,7 +4,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"zinx/znet" |
|
|
|
"github.com/aceld/zinx/znet" |
|
|
|
) |
|
|
|
|
|
|
|
//只是负责测试datapack拆包,封包功能
|
|
|
|
|
|
@ -3,7 +3,7 @@ package main |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"github.com/golang/protobuf/proto" |
|
|
|
"zinx/examples/zinx_version_ex/protoDemo/pb" |
|
|
|
"github.com/aceld/zinx/examples/zinx_version_ex/protoDemo/pb" |
|
|
|
) |
|
|
|
|
|
|
|
func main() { |
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
module zinx |
|
|
|
module github.com/aceld/zinx |
|
|
|
|
|
|
|
go 1.13 |
|
|
|
|
|
|
|
|
|
@ -4,8 +4,8 @@ import ( |
|
|
|
"encoding/json" |
|
|
|
"io/ioutil" |
|
|
|
"os" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/zlog" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/zlog" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -3,10 +3,10 @@ package api |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"github.com/golang/protobuf/proto" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/zinx_app_demo/mmo_game/core" |
|
|
|
"zinx/zinx_app_demo/mmo_game/pb" |
|
|
|
"zinx/znet" |
|
|
|
"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" |
|
|
|
) |
|
|
|
|
|
|
|
//玩家移动
|
|
|
|
|
|
@ -3,10 +3,10 @@ package api |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"github.com/golang/protobuf/proto" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/zinx_app_demo/mmo_game/core" |
|
|
|
"zinx/zinx_app_demo/mmo_game/pb" |
|
|
|
"zinx/znet" |
|
|
|
"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" |
|
|
|
) |
|
|
|
|
|
|
|
//世界聊天 路由业务
|
|
|
|
|
|
@ -11,7 +11,7 @@ import ( |
|
|
|
"os" |
|
|
|
"os/signal" |
|
|
|
"time" |
|
|
|
"zinx/zinx_app_demo/mmo_game/pb" |
|
|
|
"github.com/aceld/zinx/zinx_app_demo/mmo_game/pb" |
|
|
|
) |
|
|
|
|
|
|
|
type Message struct { |
|
|
|
|
|
@ -6,8 +6,8 @@ import ( |
|
|
|
"math/rand" |
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/zinx_app_demo/mmo_game/pb" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
"github.com/aceld/zinx/zinx_app_demo/mmo_game/pb" |
|
|
|
) |
|
|
|
|
|
|
|
//玩家对象
|
|
|
|
|
|
@ -2,10 +2,10 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"zinx/ziface" |
|
|
|
"zinx/zinx_app_demo/mmo_game/api" |
|
|
|
"zinx/zinx_app_demo/mmo_game/core" |
|
|
|
"zinx/znet" |
|
|
|
"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" |
|
|
|
) |
|
|
|
|
|
|
|
//当客户端建立连接的时候的hook函数
|
|
|
|
|
|
@ -6,8 +6,8 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"sync" |
|
|
|
"zinx/utils" |
|
|
|
"zinx/ziface" |
|
|
|
"github.com/aceld/zinx/utils" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
) |
|
|
|
|
|
|
|
type Connection struct { |
|
|
|
|
|
@ -4,7 +4,7 @@ import ( |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"sync" |
|
|
|
"zinx/ziface" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -4,8 +4,8 @@ import ( |
|
|
|
"bytes" |
|
|
|
"encoding/binary" |
|
|
|
"errors" |
|
|
|
"zinx/utils" |
|
|
|
"zinx/ziface" |
|
|
|
"github.com/aceld/zinx/utils" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
) |
|
|
|
|
|
|
|
//封包拆包类实例,暂时不需要成员
|
|
|
|
|
|
@ -3,8 +3,8 @@ package znet |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"strconv" |
|
|
|
"zinx/utils" |
|
|
|
"zinx/ziface" |
|
|
|
"github.com/aceld/zinx/utils" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
) |
|
|
|
|
|
|
|
type MsgHandle struct { |
|
|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
package znet |
|
|
|
|
|
|
|
import "zinx/ziface" |
|
|
|
import "github.com/aceld/zinx/ziface" |
|
|
|
|
|
|
|
type Request struct { |
|
|
|
conn ziface.IConnection //已经和客户端建立好的 链接
|
|
|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
package znet |
|
|
|
|
|
|
|
import "zinx/ziface" |
|
|
|
import "github.com/aceld/zinx/ziface" |
|
|
|
|
|
|
|
//实现router时,先嵌入这个基类,然后根据需要对这个基类的方法进行重写
|
|
|
|
type BaseRouter struct {} |
|
|
|
|
|
@ -3,8 +3,8 @@ package znet |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"net" |
|
|
|
"zinx/utils" |
|
|
|
"zinx/ziface" |
|
|
|
"github.com/aceld/zinx/utils" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
) |
|
|
|
|
|
|
|
var zinx_logo = ` |
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"net" |
|
|
|
"testing" |
|
|
|
"time" |
|
|
|
"zinx/ziface" |
|
|
|
"github.com/aceld/zinx/ziface" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -7,8 +7,8 @@ package ztimer |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"github.com/aceld/zinx/zlog" |
|
|
|
"reflect" |
|
|
|
"zinx/zlog" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
@ -12,7 +12,7 @@ import ( |
|
|
|
"math" |
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
"zinx/zlog" |
|
|
|
"github.com/aceld/zinx/zlog" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
@ -11,7 +11,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"testing" |
|
|
|
"time" |
|
|
|
"zinx/zlog" |
|
|
|
"github.com/aceld/zinx/zlog" |
|
|
|
) |
|
|
|
|
|
|
|
//触发函数
|
|
|
|
|
|
@ -10,7 +10,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
"zinx/zlog" |
|
|
|
"github.com/aceld/zinx/zlog" |
|
|
|
) |
|
|
|
|
|
|
|
/* |
|
|
|