Titan Panda
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 631 additions and 533 deletions
-
7examples/zinx_client/main.go
-
22examples/zinx_server/Makefile
-
21examples/zinx_server/build.sh
-
8examples/zinx_server/dockerfile
-
1examples/zinx_server/version
-
4ziface/iconnection.go
-
4ziface/imessage.go
-
2ziface/imsghandler.go
-
2ziface/iserver.go
-
13zinx_app_demo/mmo_game/api/move.go
-
11zinx_app_demo/mmo_game/api/world_chat.go
-
45zinx_app_demo/mmo_game/client_AI_robot.go
-
92zinx_app_demo/mmo_game/core/aoi.go
-
16zinx_app_demo/mmo_game/core/aoi_test.go
-
16zinx_app_demo/mmo_game/core/grid.go
-
161zinx_app_demo/mmo_game/core/player.go
-
28zinx_app_demo/mmo_game/core/world_manager.go
-
54zinx_app_demo/mmo_game/pb/msg.pb.go
-
8zinx_app_demo/mmo_game/pb/msg.proto
-
21zinx_app_demo/mmo_game/server.go
-
21zlog/stdzlog.go
-
10zlog/zlogger.go
-
68znet/connection.go
-
45znet/connmanager.go
-
17znet/datapack.go
-
6znet/datapack_test.go
-
29znet/message.go
-
29znet/msghandler.go
-
9znet/request.go
-
12znet/router.go
-
42znet/server.go
-
9znet/server_test.go
-
19ztimer/delayfunc.go
-
52ztimer/timer.go
-
128ztimer/timerscheduler.go
-
28ztimer/timerscheduler_test.go
-
72ztimer/timewheel.go
-
32ztimer/timewheel_test.go
@ -0,0 +1,22 @@ |
|||
PROJECT_NAME:=zinx_server |
|||
VERSION:=v1 |
|||
|
|||
|
|||
|
|||
.PHONY: image run build clean |
|||
|
|||
build: |
|||
bash build.sh ${PROJECT_NAME} |
|||
|
|||
image: |
|||
docker build -t ${PROJECT_NAME}:${VERSION} . |
|||
|
|||
run: |
|||
docker run -itd \
|
|||
-p 8999:8999 \
|
|||
${PROJECT_NAME}:${VERSION} |
|||
|
|||
|
|||
clean: |
|||
rm -rf ${PROJECT_NAME} |
|||
|
@ -0,0 +1,21 @@ |
|||
#!/bin/bash |
|||
|
|||
set -e |
|||
|
|||
APP_NAME=$1 |
|||
APP_VERSION=v$(cat version) |
|||
BUILD_VERSION=$(git log -1 --oneline) |
|||
BUILD_TIME=$(date "+%FT%T%z") |
|||
GIT_REVISION=$(git rev-parse --short HEAD) |
|||
GIT_BRANCH=$(git name-rev --name-only HEAD) |
|||
GO_VERSION=$(go version) |
|||
|
|||
go build -ldflags " \ |
|||
-X 'main.AppName=${APP_NAME}' \ |
|||
-X 'main.AppVersion=${APP_VERSION}' \ |
|||
-X 'main.BuildVersion=${BUILD_VERSION//\'/_}' \ |
|||
-X 'main.BuildTime=${BUILD_TIME}' \ |
|||
-X 'main.GitRevision=${GIT_REVISION}' \ |
|||
-X 'main.GitBranch=${GIT_BRANCH}' \ |
|||
-X 'main.GoVersion=${GO_VERSION}' \ |
|||
" -o $2 . |
@ -0,0 +1,8 @@ |
|||
FROM centos:8 |
|||
COPY zinx_server /zinx-server |
|||
COPY /conf/zinx.json /conf/zinx.json |
|||
WORKDIR / |
|||
EXPOSE 8999 |
|||
|
|||
ENTRYPOINT [ "/zinx-server" ] |
|||
|
@ -0,0 +1 @@ |
|||
v 1.0.0 |
@ -1,46 +1,47 @@ |
|||
package znet |
|||
|
|||
//Message 消息
|
|||
type Message struct { |
|||
DataLen uint32 //消息的长度
|
|||
Id uint32 //消息的ID
|
|||
ID uint32 //消息的ID
|
|||
Data []byte //消息的内容
|
|||
} |
|||
|
|||
//创建一个Message消息包
|
|||
func NewMsgPackage(id uint32, data []byte) *Message { |
|||
//NewMsgPackage 创建一个Message消息包
|
|||
func NewMsgPackage(ID uint32, data []byte) *Message { |
|||
return &Message{ |
|||
DataLen: uint32(len(data)), |
|||
Id: id, |
|||
ID: ID, |
|||
Data: data, |
|||
} |
|||
} |
|||
|
|||
//获取消息数据段长度
|
|||
//GetDataLen 获取消息数据段长度
|
|||
func (msg *Message) GetDataLen() uint32 { |
|||
return msg.DataLen |
|||
} |
|||
|
|||
//获取消息ID
|
|||
func (msg *Message) GetMsgId() uint32 { |
|||
return msg.Id |
|||
//GetMsgID 获取消息ID
|
|||
func (msg *Message) GetMsgID() uint32 { |
|||
return msg.ID |
|||
} |
|||
|
|||
//获取消息内容
|
|||
//GetData 获取消息内容
|
|||
func (msg *Message) GetData() []byte { |
|||
return msg.Data |
|||
} |
|||
|
|||
//设置消息数据段长度
|
|||
//SetDataLen 设置消息数据段长度
|
|||
func (msg *Message) SetDataLen(len uint32) { |
|||
msg.DataLen = len |
|||
} |
|||
|
|||
//设计消息ID
|
|||
func (msg *Message) SetMsgId(msgId uint32) { |
|||
msg.Id = msgId |
|||
//SetMsgID 设计消息ID
|
|||
func (msg *Message) SetMsgID(msgID uint32) { |
|||
msg.ID = msgID |
|||
} |
|||
|
|||
//设计消息内容
|
|||
//SetData 设计消息内容
|
|||
func (msg *Message) SetData(data []byte) { |
|||
msg.Data = data |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue