nakama README

The project's README from github.com/heroiclabs/nakama. As one markdown file: README.md.

Nakama - Distributed server for social and realtime games and apps

Version Downloads License Nakama Forum Nakama Documentation

Features

Build scalable games and apps with a production ready server used by ambitious game studios and app developers all around the world. Have a look at the documentation and join the developer community for more info.

Getting Started

The server is simple to setup and run for local development and can be deployed to any cloud provider. See the deployment notes for recommendations on how to deploy the project for production. Nakama server requires CockroachDB or another Postgres wire-compatible server as it's database.

Docker

The fastest way to run the server and the database is with Docker. Setup Docker and start the daemon.

  1. Set up a docker-compose file and place it in a folder for your project.

  2. Run docker-compose -f ./docker-compose.yml up to download container images and run the servers.

For more detailed instructions have a look at our Docker quickstart guide.

Nakama Docker images are maintained on Docker Hub and prerelease images are occasionally published for cutting edge features of the server.

Binaries

You can run the servers with native binaries for your platform.

  1. Download the server from our releases page and the database.

  2. Follow the database instructions to start it.

  3. Run a migration which will setup or upgrade the database schema:

    nakama migrate up --database.address "[email protected]:26257"
    
  4. Start Nakama and connect to the database:

    nakama --database.address "[email protected]:26257"
    

When connected you'll see server output which describes all settings the server uses for configuration.

{"level":"info","ts":"2018-04-29T10:14:41.249+0100","msg":"Node","name":"nakama","version":"2.0.0+7e18b09","runtime":"go1.10.1","cpu":4}
{"level":"info","ts":"2018-04-29T10:14:41.249+0100","msg":"Database connections","dsns":["[email protected]:26257"]}
...

Usage

Nakama supports a variety of protocols optimized for various gameplay or app use cases. For request/response it can use GRPC or the HTTP1.1+JSON fallback (REST). For realtime communication you can use WebSockets or rUDP.

For example with the REST API to authenticate a user account with a device identifier.

curl "127.0.0.1:7350/v2/account/authenticate/device?create=true" \
  --user "defaultkey:" \
  --data '{"id": "someuniqueidentifier"}'

Response:

{
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MjQ5OTU2NDksInVpZCI6Ijk5Y2Q1YzUyLWE5ODgtNGI2NC04YThhLTVmMTM5YTg4MTgxMiIsInVzbiI6InhBb1RxTUVSdFgifQ.-3_rXNYx3Q4jKuS7RkxeMWBzMNAm0vl93QxzRI8p_IY"
}

There's a number of official client libraries available on GitHub with documentation. The current platform/language support includes: .NET (in C#), Unity engine, JavaScript, Java (with Android), Unreal engine, Godot, Defold, and Swift (with iOS). If you'd like to contribute a client or request one let us know.

Nakama Console

The server provides a web UI which teams can use to inspect various data stored through the server APIs, view lightweight service metrics, manage player data, update storage objects, restrict access to production with permission profiles, and gain visibility into realtime features like active multiplayer matches. There is no separate installation required as it is embedded as part of the single server binary.

You can navigate to it on your browser on http://127.0.0.1:7351.

View Screenshots Nakama Console dashboard view Nakama Console players view Nakama Console API explorer view Nakama Console storage view Nakama Console modules view

Deployment

Nakama can be deployed to any cloud provider such as Google Cloud, Azure, AWS, Digital Ocean, Heroku, or your own private cloud. You should setup and provision separate nodes for Nakama and CockroachDB.

The recommended minimum production infrastructure for CockroachDB is outlined in these docs and Nakama can be run on instance types as small as "g1-small" on Google Cloud although we recommend a minimum of "n1-standard-1" in production. The specific hardware requirements will depend on what features of the server are used. Reach out to us for help and advice on what servers to run.

Heroic Cloud

You can support development, new features, and maintainance of the server by using the Heroic Labs' Heroic Cloud for deployment. This service handles the uptime, replication, backups, logs, data upgrades, and all other tasks involved with production server environments.

Have a look at our Heroic Cloud service for more details.

Contribute

The development roadmap is managed as GitHub issues and pull requests are welcome. If you're interested to add a feature which is not mentioned on the issue tracker please open one to create a discussion or drop in and discuss it in the community forum.

Simple Builds

All dependencies required for a build are vendored as part of the Go project. We recommend a modern release of the Go toolchain and do not store the codebase in the old GOPATH.

  1. Download the source tree.

    git clone "https://github.com/heroiclabs/nakama" nakama
    cd nakama
    
  2. Build the project from source.

    go build -trimpath -mod=vendor
    ./nakama --version
    

Full Source Builds

The codebase uses Protocol Buffers, GRPC, GRPC-Gateway, buf, and the OpenAPI spec as part of the project. These dependencies are generated as sources and committed to the repository to simplify builds for contributors.

To build the codebase and generate all sources follow these steps.

  1. Install the toolchain.

    go install \
        "google.golang.org/protobuf/cmd/protoc-gen-go" \
        "google.golang.org/grpc/cmd/protoc-gen-go-grpc" \
        "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway" \
        "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2"
    
  2. Install buf.

  3. Re-generate the protocol buffers and gateway code.

    # Run the shell script:
    ./buf.sh
    
  4. Build the codebase.

    go build -trimpath -mod=vendor
    

Testing

In order to run all the unit and integration tests run:

docker-compose -f ./docker-compose-tests.yml up --build --abort-on-container-exit; docker-compose -f ./docker-compose-tests.yml down -v

This will create an isolated environment with Nakama and database instances, run all the tests, and drop the environment afterwards.

License

This project is licensed under the Apache-2 License.

nakama (heroiclabs/nakama)

Searching Database…

13.5K ·GitHub
这是什么?Nakama 是一款可扩展的开源游戏服务器,提供多人联机、匹配、排行榜、锦标赛、聊天、组队和社交功能,让游戏工作室无需从零搭建后端基础设施。
这是我要导入的库,还是我需要自己运行的独立服务器?它是一个独立的服务器程序(或 Docker 容器),你的游戏客户端通过 GRPC、REST、WebSockets 或 rUDP 与它连接。针对 Unity、Unreal、Godot、.NET、JavaScript、Java/Android 和 Swift/iOS 都有客户端 SDK。
我该怎么把它跑起来?最快的方法是使用 Docker:准备一个 docker-compose 文件,然后运行 'docker-compose -f ./docker-compose.yml up'。也可以下载原生二进制文件,执行数据库迁移,再启动连接该数据库的 Nakama。
我需要专门的数据库吗?需要。Nakama 要求使用 CockroachDB 或其他兼容 Postgres 协议的数据库作为存储后端。
我能扩展服务器逻辑吗?可以用什么语言?可以。你可以用 Lua、TypeScript/JavaScript 或原生 Go 代码编写自定义运行时逻辑,从而扩展服务器的内置功能。
它官方支持哪些游戏引擎?官方客户端库支持 Unity、Unreal Engine、Godot、Defold,以及用于自定义应用的 .NET/C#、JavaScript、Java/Android 和 Swift/iOS。
我可以把它部署在哪里?Nakama 可以部署到任何云服务商,例如 Google Cloud、Azure、AWS、Digital Ocean、Heroku,或你自己的私有基础设施上。该厂商还提供托管选项“Heroic Cloud”。
它有管理后台吗?有。游戏服务器程序内嵌了一个名为 Nakama Console 的网页界面,团队无需单独安装,就能查看存储的数据和指标、管理玩家数据,并监控正在进行的多人对局。
它支持哪些实时通信协议?实时游戏玩法支持 WebSockets 或 rUDP,请求/响应类调用可以使用 GRPC,也可以使用 HTTP1.1+JSON REST 作为备选。
它内置了哪些社交和变现功能?开箱即用,支持社交登录(社交网络、邮箱、设备 ID)、好友和群组、带历史记录的聊天、排行榜和锦标赛、组队、应用内购买验证,以及向已连接客户端推送通知。
如果我不想自己运行,有托管服务吗?有。Heroic Labs 提供付费托管服务“Heroic Cloud”,负责处理运行时间保障、数据复制、备份、日志和升级。
Creator
heroiclabs
Size
168.5 MB
Stars
13.5K
Age
9y
Commits · 90 Days