From 46e8de9a2a7239647b529602af8aeb135c8956cf Mon Sep 17 00:00:00 2001 From: koangel Date: Mon, 24 Jul 2017 23:18:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84SERVER=E5=8E=8B=E5=8A=9B?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=EF=BC=8C=E7=9B=AE=E5=89=8D=E5=8F=AF=E6=89=BF?= =?UTF-8?q?=E5=8F=975000+=20TCP=E8=BF=9E=E6=8E=A5=EF=BC=88LINE=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=EF=BC=89=20=E7=A8=8D=E5=90=8E=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=9C=A8=E7=BA=BF=E4=BD=93=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ CGCrypt/Crypt.go | 3 +++ README.md | 16 ++++++++++++ Tests/Client_test/main.go | 13 ++++++++++ Tests/Network_test/main.go | 50 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 .gitignore create mode 100644 CGCrypt/Crypt.go create mode 100644 README.md create mode 100644 Tests/Client_test/main.go create mode 100644 Tests/Network_test/main.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..05fb978 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +Tests/Network_test/log/normal.log +Tests/Network_test/debug +/Tests/Network_test/log diff --git a/CGCrypt/Crypt.go b/CGCrypt/Crypt.go new file mode 100644 index 0000000..cb64d6a --- /dev/null +++ b/CGCrypt/Crypt.go @@ -0,0 +1,3 @@ +// 2017-07-23 +// cg 加解密函数 +package CGCrypt diff --git a/README.md b/README.md new file mode 100644 index 0000000..6d9c3b7 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# GrapeCG是什么项目 + +GrapeCG是CrossGate(大陆译为:魔力宝贝)的一款服务器端模拟器,仅仅模拟部分功能。 + +# 发起原因 + +本人在上学时特别喜欢CG这款游戏,但是当时碍于学习几乎被限制,后来再玩也就不是那个感觉了,其实是CG这款游戏让我立志进入游戏行业,并一步步走到今日。 + +发起本项目并不是为了盈利纯粹就是个人爱好,我比较喜欢这个游戏就深入研究了这个游戏在韩国地区泄露的服务端的协议,并模拟了基本的框架和加解密,目的是为了借CG这款游戏来完善在GO语言方面的游戏服务端框架编写。 + +# 目前可以做什么 + +目前本模拟器刚刚起步,应该只可以做到基本的逛地图,而本人并不是特别有空,所以也就是学习之用,慢慢完善吧。 + +如果框架编写差不多了,基本上也就不会再去维护和更新了。 + diff --git a/Tests/Client_test/main.go b/Tests/Client_test/main.go new file mode 100644 index 0000000..15e9885 --- /dev/null +++ b/Tests/Client_test/main.go @@ -0,0 +1,13 @@ +// 2017-07-24 +// 测试网络层基本收法行为 +package main + +import ( + gnet "github.com/koangel/grapeNet/Net" +) + +func main() { + vnet := gnet.NewEmptyTcp() // 创建一个空的对象 + + vnet.Runnable() +} diff --git a/Tests/Network_test/main.go b/Tests/Network_test/main.go new file mode 100644 index 0000000..253ec20 --- /dev/null +++ b/Tests/Network_test/main.go @@ -0,0 +1,50 @@ +// 2017-07-24 +// 测试网络层基本收法行为 +package main + +import ( + "log" + "runtime" + + logger "github.com/koangel/grapeNet/Logger" + gnet "github.com/koangel/grapeNet/Net" + + "net/http" + _ "net/http/pprof" +) + +type userData struct { + userName string +} + +func CreateOwner() interface{} { + return &userData{} +} + +func HandleData(conn *gnet.TcpConn, ownerPak []byte) { + logger.INFO("recv Data:%v - pak:%v", conn.SessionId, string(ownerPak)) +} + +func main() { + // 设置并行运行 + runtime.GOMAXPROCS(runtime.NumCPU()) + + curDir := logger.GetCurrentDirectory() + "/log" + logger.BuildLogger(curDir, "normal.log") + logger.INFO("Test Server Start...") + cnet, err := gnet.NewTcpServer(":9923") + if err != nil { + logger.FLUSH() + return + } + + go func() { + log.Println(http.ListenAndServe("localhost:7777", nil)) + }() + + cnet.Unpackage = gnet.DefaultLineData + cnet.OnHandler = HandleData + cnet.CreateUserData = CreateOwner + + cnet.Runnable() +}