Nakama: An open-source online multiplayer gaming framework

Nakama: An open-source online multiplayer gaming framework

2022-10-10 0 1,050
Resource Number 44924 Last Updated 2025-02-24
¥ 0HKD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

The Nakama recommended in this issue is an open-source online multiplayer gaming framework.

Nakama: An open-source online multiplayer gaming framework插图

Nakama is an open-source online multiplayer game framework consisting of an extensible server framework and various client SDKs that can add powerful features to your game.

Customer concept: Connect to your Nakama server and use Nakama social and competitive features to build your game:

Server Framework: The most advanced game server that can be fully extended using Go, TypeScript/JavaScript, and Lua to create server authoritative game logic and advanced features, and better control permissions, storage engines, and direct database access when needed.

project Properties

  • Users – Register/log in as new users through social networks, email, or device ID.
  • Storage – Store user records, settings, and other objects in a collection.
  • Social – Users can contact friends and join groups. Built in social graph to see how to connect users.
  • Chat – one-on-one, group, and global chatting between users. Keep chat records for messages.
  • Multiplayer – Real time or turn based active and passive multiplayer games.
  • Leaderboards – dynamic, seasonal, gaining top members or members around users. There are as many as possible.
  • Tournaments – Invite players to compete for prizes together. Connect many people together to create a league.
  • Parts – Add team games to the game. Users can form teams and communicate with party members.
  • Runtime code – Use custom logic extension servers written in Lua, TypeScript/JavaScript, or native Go code.

Quick start

Install Nakama using Docker Compose

  • Install to the original environment
  • Easy installation and operation of CockrachDB or PostgreSQL databases for Nakama
  • Take snapshots, delete and reinstall Nakama without affecting your primary operating system
  • No matter what your operating system is, you can enjoy a fast and simplified installation experience

Run Nakama

Firstly, create a directory where your Nakama server is located, such as Desktop/Nakama

Create a docker-compose.yml file in this folder and open it using your favorite text editor.

Heroic Labs provides two YML files for use: using CockroachDB or PostgreSQL as the database.

docker-compose.yml:

version: '3'
services:
  cockroachdb:
    image: cockroachdb/cockroach:latest-v20.2
    command: start-single-node --insecure --store=attrs=ssd,path=/var/lib/cockroach/
    restart: "no"
    volumes:
      - data:/var/lib/cockroach
    expose:
      - "8080"
      - "26257"
    ports:
      - "26257:26257"
      - "8080:8080"
  nakama:
    image: heroiclabs/nakama:3.9.0
    entrypoint:
      - "/bin/sh"
      - "-ecx"
      - >
        /nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
        exec /nakama/nakama --name nakama1 --database.address root@cockroachdb:26257 --logger.level DEBUG --session.token_expiry_sec 7200 --metrics.prometheus_port 9100        
    restart: "no"
    links:
      - "cockroachdb:db"
    depends_on:
      - cockroachdb
      - prometheus
    volumes:
      - ./:/nakama/data
    expose:
      - "7349"
      - "7350"
      - "7351"
      - "9100"
    ports:
      - "7349:7349"
      - "7350:7350"
      - "7351:7351"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7350/"]
      interval: 10s
      timeout: 5s
      retries: 5
  prometheus:
    image: prom/prometheus
    entrypoint: /bin/sh -c
    command: |
      'sh -s <<EOF
        cat > ./prometheus.yml <<EON
      global:
        scrape_interval:     15s
        evaluation_interval: 15s
      scrape_configs:
        - job_name: prometheus
          static_configs:
          - targets: ['localhost:9090']
        - job_name: nakama
          metrics_path: /
          static_configs:
          - targets: ['nakama:9100']
      EON
      prometheus --config.file=./prometheus.yml
      EOF'      
    ports:
      - '9090:9090'
volumes:
  data:

docker-compose-postgres.yml:

version: '3'
services:
  postgres:
    container_name: postgres
    image: postgres:9.6-alpine
    environment:
      - POSTGRES_DB=nakama
      - POSTGRES_PASSWORD=localdb
    volumes:
      - data:/var/lib/postgresql/data
    expose:
      - "8080"
      - "5432"
    ports:
      - "5432:5432"
      - "8080:8080"
  nakama:
    container_name: nakama
    image: heroiclabs/nakama:3.9.0
    entrypoint:
      - "/bin/sh"
      - "-ecx"
      - >
        /nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama &&
        exec /nakama/nakama --name nakama1 --database.address postgres:localdb@postgres:5432/nakama --logger.level DEBUG --session.token_expiry_sec 7200        
    restart: always
    links:
      - "postgres:db"
    depends_on:
      - postgres
    volumes:
      - ./:/nakama/data
    expose:
      - "7349"
      - "7350"
      - "7351"
    ports:
      - "7349:7349"
      - "7350:7350"
      - "7351:7351"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7350/"]
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  data:

Copy and paste the content of the preferred options into the docker-compose.yml file.

Open a terminal window and navigate to your Nakama directory. For example:

cd desktop/nakama

To extract all necessary images and launch your application, run the following command:

docker compose up

Congratulations! Your Nakama server is now up and running, available at 127.0.0.1:7350

Nakama: An open-source online multiplayer gaming framework插图1

Middle console

You can also access the Nakama console by navigating your browser to 127.0.0.1:7351:

Nakama: An open-source online multiplayer gaming framework插图2

configuration file

You can customize many available configuration options for Nakama servers. You can create a YML file for all the configurations you want to set up and pass it to your Docker container.

Firstly, you need to provide a local storage volume for Docker:

1 docker-compose.yml Open your file in your favorite text editor.

Edit Nakama: volumes: entry to specify the desired volume. For example, to create a folder for/data in the directory we use on desktop/nakama, which can be used in Docker containers with nakama/data, it is as follows:

volumes:
– ./ data:/nakama/data

Save the modified file and restart the Docker container for the changes to take effect. From your terminal:

docker compose restart

Next, create your custom configuration file, such as my-config.yml, and place it in the folder you provided for Docker on/data.

my-config.yml:

name: nakama-node-1
data_dir: "./data/"

logger:
    stdout: false
    level: "warn"
    file: "/nakama/data/logfile.log"

console:
    port: 7351
    username: "my_user"
    password: "my_password"

Open your docker-compose.yml file again, and this time edit the nakama: entrypoint entry to add the — config flag pointing to your configuration file. It should be as follows:

nakama:
    entrypoint:
    - "/bin/sh"
    - "-ecx"
    - >
        /nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
        /nakama/nakama --config /nakama/data/my-config.yml  

Save the changed file and restart the Docker container for the changes to take effect. From your terminal:

docker compose restart

Project Preview

Status:

The status page provides a real-time view of the Nakama server, including usage details for each node and a general view of bandwidth and latency, including:

  • Delay: The time, in milliseconds (ms), taken to execute a remote procedure call (RPC) function
  • Rate: RPC count per second
  • Input: Inbound traffic in kilobytes per second (kb/s)
  • Output: Outbound traffic in kilobytes per second (kb/s)

Nakama: An open-source online multiplayer gaming framework插图3

User management:

The user management page allows you to add new console users or delete any existing users. When creating a new user, there are four available roles that allow you to set up a support team that can only access the UI features they need.

Nakama: An open-source online multiplayer gaming framework插图4

Runtime modules:

The runtime module page allows you to easily observe which functions in the project are active and when they were last modified.

Nakama: An open-source online multiplayer gaming framework插图5

Accounts:

The Accounts page displays a list of all user accounts, which can be searched based on user ID and username. From here, you can view, edit, and delete any user.

Nakama: An open-source online multiplayer gaming framework插图6

Leaderboards:

The leaderboard page allows you to view and manage your leaderboards and tournaments, as well as their corresponding records.

Nakama: An open-source online multiplayer gaming framework插图7

—END—

Open source license: Apache-2.0 License

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free Source Code Nakama: An open-source online multiplayer gaming framework https://ictcoder.com/nakama-an-open-source-online-multiplayer-gaming-framework/

Share free open-source source code

Q&A
  • 1. Automatic: After making an online payment, click the (Download) link to download the source code; 2. Manual: Contact the seller or the official to check if the template is consistent. Then, place an order and make payment online. The seller ships the goods, and both parties inspect and confirm that there are no issues. ICTcoder will then settle the payment for the seller. Note: Please ensure to place your order and make payment through ICTcoder. If you do not place your order and make payment through ICTcoder, and the seller sends fake source code or encounters any issues, ICTcoder will not assist in resolving them, nor can we guarantee your funds!
View details
  • 1. Default transaction cycle for source code: The seller manually ships the goods within 1-3 days. The amount paid by the user will be held in escrow by ICTcoder until 7 days after the transaction is completed and both parties confirm that there are no issues. ICTcoder will then settle with the seller. In case of any disputes, ICTcoder will have staff to assist in handling until the dispute is resolved or a refund is made! If the buyer places an order and makes payment not through ICTcoder, any issues and disputes have nothing to do with ICTcoder, and ICTcoder will not be responsible for any liabilities!
View details
  • 1. ICTcoder will permanently archive the transaction process between both parties and snapshots of the traded goods to ensure the authenticity, validity, and security of the transaction! 2. ICTcoder cannot guarantee services such as "permanent package updates" and "permanent technical support" after the merchant's commitment. Buyers are advised to identify these services on their own. If necessary, they can contact ICTcoder for assistance; 3. When both website demonstration and image demonstration exist in the source code, and the text descriptions of the website and images are inconsistent, the text description of the image shall prevail as the basis for dispute resolution (excluding special statements or agreements); 4. If there is no statement such as "no legal basis for refund" or similar content, any indication on the product that "once sold, no refunds will be supported" or other similar declarations shall be deemed invalid; 5. Before the buyer places an order and makes payment, the transaction details agreed upon by both parties via WhatsApp or email can also serve as the basis for dispute resolution (in case of any inconsistency between the agreement and the description of the conflict, the agreement shall prevail); 6. Since chat records and email records can serve as the basis for dispute resolution, both parties should only communicate with each other through the contact information left on the system when contacting each other, in order to prevent the other party from denying their own commitments. 7. Although the probability of disputes is low, it is essential to retain important information such as chat records, text messages, and email records, in case a dispute arises, so that ICTcoder can intervene quickly.
View details
  • 1. As a third-party intermediary platform, ICTcoder solely protects transaction security and the rights and interests of both buyers and sellers based on the transaction contract (product description, agreed content before the transaction); 2. For online trading projects not on the ICTcoder platform, any consequences are unrelated to this platform; regardless of the reason why the seller requests an offline transaction, please contact the administrator to report.
View details

Related Source code

ICTcoder Customer Service

24-hour online professional services