Coder Social home page Coder Social logo

mqantserver's Introduction

快速使用

获取 mqantserver:

git clone https://github.com/liangdas/mqantserver

mqant 2x开始支持分布式服务发现

请务必先查看2x跟1x版本差异

依赖组件

必须启动的组件有

  1. consul

    consul agent --dev

  2. nats

    gnats

由社区提供的docker环境

mqant-docker

go.mod 用法

mqantserver 只支持golang1.2版本以上的go.mod方式编译

翻墙

golang.org/x/net 等库无法下载的问题

export GOPROXY=https://goproxy.io

编译 mqantserver:

go install server/main.go

go build server/main.go

如果一切顺利,运行 main 你可以获得以下输出:

./main --conf bin/conf/server.json --log bin/logs

[release] mqant 1.0.0 starting up
[debug  ] RPCClient create success type(Gate) id(127.0.0.1:Gate)
[debug  ] RPCClient create success type(Login) id(127.0.0.1:Login)
[debug  ] RPCClient create success type(Chat) id(127.0.0.1:Chat)
[release] MySelfHost 172.16.8.4
[release] WS Listen :%!(EXTRA string=0.0.0.0:3653)
[release] TCP Listen :%!(EXTRA string=0.0.0.0:3563)

敲击 Ctrl + C 关闭游戏服务器,服务器正常关闭输出:

[debug  ] RPCServer close success id(127.0.0.1:Chat)
[debug  ] RPCServer close success id(127.0.0.1:Login)
[debug  ] RPCServer close success id(127.0.0.1:Gate)
[debug  ] RPCClient close success type(Gate) id(127.0.0.1:Gate)
[debug  ] RPCClient close success type(Login) id(127.0.0.1:Login)
[debug  ] RPCClient close success type(Chat) id(127.0.0.1:Chat)
[release] mqant closing down (signal: interrupt)

更改web服务器文件访问本地路径

bin/conf/server.conf 中

"Webapp":[
                        {
                            "Id":"Webapp001",
                            "ProcessID":"development",
                            "Settings":{
                                "StaticPath":"/work/go/mqantserver/bin"
                            }
                        }
                ],
其中StaticPath 更改为你本机上mqantserver bin的绝对路径

访问网页版本客户端

mqantserver已内置了一个web模块(源码在server/webapp),因此进程启动成功以后就可以访问了

访问地址为:http://127.0.0.1:8080/mqant/chat/index.html

小球碰撞游戏DEMO访问地址为:http://127.0.0.1:8080/mqant/hitball/index.html

猜数字游戏

猜数字游戏无网页模块,而是实现了一个golang的后端机器人来模拟整个逻辑

机器人代码在src/robot下,需要依赖github.com/liangdas/armyant

Demo演示说明

1. 启动服务器
2. 启动网页客户端	(默认房间名,用户名)
3. 登陆成功后就可以聊天了

分布式跟踪系统功能测试

Appdash,用Go实现的分布式系统跟踪神器

客户端访问Chat/HD_JoinChat/{msgid}时后端将会收集访问信息,通过以下地址就可以看到了 访问地址 http://localhost:7700

示意图: 示意图

项目目录结构

https://github.com/liangdas/mqantserver 仓库中包含了mqant框架,所用到的第三方库,聊天Demo服务端,聊天代码客户端代码

bin		
	|-conf/server.json			服务端配置文件
	|-public					web客户端静态文件
	|-hitball					小球碰撞游戏DEMO客户端文件
	|-console                   控制台web静态文件(还未完成)
src
	|-client
		|-mqtt_chat_client.py 	聊天客户端 Python版本
		|-webclient.go			聊天客户端网页版本
	|-hitball						小球碰撞游戏DEMO客户端源码
	|-server						聊天服务器Demo
		|-gate						网关模块
		|-chat						聊天模块
		|-login						登陆模块
		|-hitball					小球碰撞游戏模块
		|-tracing					分布式跟踪系统服务模块
		|-main.go					服务器启动入口

客户端快速测试

如果你需要测试其他语言的mqtt客户端,可以使用mqant提供的测试接口来测试

tcp mqtt :

host: mqant.com
port: 3563
protocol=mqtt.MQTTv31
tcp:  tls/TLSv1

如果客户端需要ca证书可以使用下面这个网站提供的
https://curl.haxx.se/docs/caextract.html

websocket mqtt :

host: ws://www.mqant.com:3653/mqant
protocol=mqtt.MQTTv31

测试协议

  1. 登陆接口

     向服务器publish一条登陆消息
    
     topic:		Login/HD_Login/{msgid}
     
     message:	{"userName": "liangdas", "passWord": "Hello,anyone!"}
    

    如果topic添加了msgid,则服务器会返回一条回复消息

  2. 加入聊天室

     向服务器publish一条登陆消息
    
     topic:		Chat/HD_JoinChat/{msgid}
     
     message:	{"roomName": "mqant"}
    
     服务器会广播消息给所有聊天室成员
     
     topic:		Chat/OnJoin
     	
     message:	{"users": [“liangdas”]}
    
  3. 发送一条聊天

     向服务器publish一条登陆消息
    
     topic:		Chat/HD_Say/{msgid}
     
     message:	{"roomName": "mqant","from":"liangdas","target":"*","content": "大家好!!"}
    
     服务器会广播消息给所有聊天室成员
     
     topic:		Chat/OnChat
     	
     message:	{"roomName": "mqant","from":"liangdas","target":"*","msg":"大家好!!"}
    

mqantserver's People

Contributors

liangdas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mqantserver's Issues

您好, 請問在測試robot時發生以下錯誤怎麼解決

2018-09-12T19:13:43+08:00 [-] [-] [development] [E] [rpc_server.go:263] RPC Exec ModuleType = Gate Func = SendBatch Elapsed = 0s ERROR:
The number of params [[51 99 100 56 48 52 97 53 48 49 102 101 50 101 50 102 44 55 55 100 49 53 50 98 57 52 98 102 57 50 55 57 98] [88 97 88 98 47 73 100 108 101] [123 34 67 111 105 110 34 58 53 48 48 125]] is not adapted.<func(log.TraceSpan, string, string, []uint8) (int64, string) Value>
github.com/liangdas/mqant/rpc/base/rpc_server.go:263
github.com/liangdas/mqant/rpc/base/rpc_server.go:297
github.com/liangdas/mqant/rpc/base/rpc_server.go:248

請問有大神知道為什麼嗎

go mod vender 报错

mqantserver/src/robot imports
robot/xaba: malformed module path "robot/xaba": missing dot in first path element

需要在:xaxb_task.go import mqantserver/src/robot/xaba

windows 10-64bit

nats: no servers available for connection nats://127.0.0.1:4222

[ERR] consul.watch: Watch (type: services) errored: Get http://127.0.0.1:8500/v1/catalog/services: dial tcp 127.0.0.1:8500: connectex: No connection could be made because the target machine actively refused it., retry in 5s

你好,遇见以下这两个问题怎么解决

1:go get github.com/liangdas/mqant-modules这个模块无法安装

2:在go install server下安装会出现这个错误

server/xaxb/objects

src/server/xaxb/objects/player.go:46:23: this.BasePlayerImp.Session().GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)

server/chat

src/server/chat/RPCListener.go:30:12: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/chat/module.go:64:2: undefined: "github.com/liangdas/mqant/log".TInfo
src/server/chat/module.go:65:12: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/chat/module.go:73:2: undefined: "github.com/liangdas/mqant/log".TInfo
src/server/chat/module.go:78:45: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/chat/module.go:89:19: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/chat/module.go:94:24: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/chat/module.go:101:10: user.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/chat/module.go:101:33: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/chat/module.go:106:29: user.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/chat/module.go:106:29: too many errors

server/gate

src/server/gate/CustomAgent.go:110:22: this.GetSession().GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/gate/CustomAgent.go:116:62: this.GetSession().GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/gate/module.go:68:12: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)

server/login

src/server/login/module.go:74:2: undefined: "github.com/liangdas/mqant/log".TInfo
src/server/login/module.go:82:2: undefined: "github.com/liangdas/mqant/log".TInfo
src/server/login/module.go:93:2: undefined: "github.com/liangdas/mqant/log".TInfo

server/hitball

src/server/hitball/module.go:68:12: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/hitball/table.go:241:35: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/hitball/table.go:252:15: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)
src/server/hitball/table.go:286:35: session.GetUserId undefined (type gate.Session has no field or method GetUserId, but does have GetUserid)

没有client/public文件

我在src/client编译,执行client提示没有client/public文件,发现代码里确实没有包含该文件

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.