All Projects → heroiclabs → Nakama Godot

heroiclabs / Nakama Godot

Licence: apache-2.0
Godot client for Nakama server written in GDScript.

Projects that are alternatives of or similar to Nakama Godot

Nakama Unity
Unity client for Nakama server.
Stars: ✭ 222 (-7.5%)
Mutual labels:  social, multiplayer, chat, realtime
Nakama
Distributed server for social and realtime games and apps.
Stars: ✭ 5,293 (+2105.42%)
Mutual labels:  social, multiplayer, realtime
Opensource Socialnetwork
Open Source Social Network (OSSN) is a social networking software written in PHP. It allows you to make a social networking website and helps your members build social relationships, with people who share similar professional or personal interests. It is available in 16 international languages.
Stars: ✭ 710 (+195.83%)
Mutual labels:  social, chat
Chat21 Ios Sdk
DEPRECATED
Stars: ✭ 15 (-93.75%)
Mutual labels:  chat, realtime
Kotlin Firebase Group Chat
Group and OneonOne chat using firebase built in Kotlin similar to whatsapp.
Stars: ✭ 44 (-81.67%)
Mutual labels:  chat, realtime
Rpc Websockets
JSON-RPC 2.0 implementation over WebSockets for Node.js and JavaScript/TypeScript
Stars: ✭ 344 (+43.33%)
Mutual labels:  multiplayer, chat
Applozic Android Sdk
Android Real Time Chat & Messaging SDK
Stars: ✭ 611 (+154.58%)
Mutual labels:  chat, realtime
Nakama Cpp
Generic C/C++ client for Nakama server.
Stars: ✭ 38 (-84.17%)
Mutual labels:  social, multiplayer
mangband
A free online multi-player realtime roguelike game based on Angband
Stars: ✭ 54 (-77.5%)
Mutual labels:  multiplayer, realtime
Gophergameserver
🏆 Feature packed, easy-to-use game server API for Go back-ends and Javascript clients. Tutorials and examples included!
Stars: ✭ 61 (-74.58%)
Mutual labels:  multiplayer, chat
Vynchronize
Watch videos with friends online with the new real time video synchronization platform
Stars: ✭ 1,072 (+346.67%)
Mutual labels:  social, realtime
Janus Server
JanusVR Presence Server
Stars: ✭ 73 (-69.58%)
Mutual labels:  multiplayer, chat
Chat Realtime
Public & Private message. MySQL & Firebase.
Stars: ✭ 147 (-38.75%)
Mutual labels:  chat, realtime
Laravel Video Chat
Laravel Video Chat using Socket.IO and WebRTC
Stars: ✭ 646 (+169.17%)
Mutual labels:  chat, realtime
Eureca.io
eureca.io : a nodejs bidirectional RPC that can use WebSocket, WebRTC or XHR fallback as transport layers
Stars: ✭ 341 (+42.08%)
Mutual labels:  multiplayer, realtime
Vuejs Slack Clone Realtime
Slack clone using VueJS and firebase
Stars: ✭ 33 (-86.25%)
Mutual labels:  chat, realtime
SocketIOUnity
A Wrapper for socket.io-client-csharp to work with Unity.
Stars: ✭ 69 (-71.25%)
Mutual labels:  multiplayer, realtime
syncwatch
Browser extension to watch videos together
Stars: ✭ 48 (-80%)
Mutual labels:  social, realtime
Tiledesk Dashboard
The Tiledesk dashboard. Tiledesk is an Open Source Live Chat platform written in NodeJs, firebase and Angular.
Stars: ✭ 53 (-77.92%)
Mutual labels:  chat, realtime
Chat Ui Kit React
Build your own chat UI with React components in few minutes. Chat UI Kit from chatscope is an open source UI toolkit for developing web chat applications.
Stars: ✭ 131 (-45.42%)
Mutual labels:  social, chat

Nakama Godot

Godot client for Nakama server written in GDScript.

Nakama is an open-source server designed to power modern games and apps. Features include user accounts, chat, social, matchmaker, realtime multiplayer, and much more.

This client implements the full API and socket options with the server. It's written in GDScript to support Godot Engine 3.1+.

Full documentation is online - https://heroiclabs.com/docs

Getting Started

You'll need to setup the server and database before you can connect with the client. The simplest way is to use Docker but have a look at the server documentation for other options.

  1. Install and run the servers. Follow these instructions.

  2. Download the client from the releases page and import it into your project. You can also download it from the asset repository.

  3. Add the Nakama.gd singleton (in addons/com.heroiclabs.nakama/) as an autoload in Godot.

  4. Use the connection credentials to build a client object using the singleton.

    extends Node
    
    func _ready():
    	var scheme = "http"
    	var host = "127.0.0.1"
    	var port = 7350
    	var server_key = "defaultkey"
    	var client := Nakama.create_client(server_key, host, port, scheme)
    

Usage

The client object has many methods to execute various features in the server or open realtime socket connections with the server.

Authenticate

There's a variety of ways to authenticate with the server. Authentication can create a user if they don't already exist with those credentials. It's also easy to authenticate with a social profile from Google Play Games, Facebook, Game Center, etc.

	var email = "[email protected]"
	var password = "batsignal"
	# Use yield(client.function(), "completed") to wait for the request to complete.
	var session : NakamaSession = yield(client.authenticate_email_async(email, password), "completed")
	print(session)

Sessions

When authenticated the server responds with an auth token (JWT) which contains useful properties and gets deserialized into a NakamaSession object.

	print(session.token) # raw JWT token
	print(session.user_id)
	print(session.username)
	print("Session has expired: %s" % session.expired)
	print("Session expires at: %s" % session.expire_time)

It is recommended to store the auth token from the session and check at startup if it has expired. If the token has expired you must reauthenticate. The expiry time of the token can be changed as a setting in the server.

	var authtoken = "restored from somewhere"
	var session2 = NakamaClient.restore_session(authtoken)
	if session2.expired:
		print("Session has expired. Must reauthenticate!")

NOTE: The length of the lifetime of a session can be changed on the server with the --session.token_expiry_sec command flag argument.

Requests

The client includes lots of builtin APIs for various features of the game server. These can be accessed with the async methods. It can also call custom logic in RPC functions on the server. These can also be executed with a socket object.

All requests are sent with a session object which authorizes the client.

	var account = yield(client.get_account_async(session), "completed")
	print(account.user.id)
	print(account.user.username)
	print(account.wallet)

Exceptions

Since Godot Engine does not support exceptions, whenever you make an async request via the client or socket, you can check if an error occurred via the is_exception() method.

	var an_invalid_session = NakamaSession.new() # An empty session, which will cause and error when we use it.
	var account2 = yield(client.get_account_async(an_invalid_session), "completed")
	print(account2) # This will print the exception
	if account2.is_exception():
		print("We got an exception")

Socket

The client can create one or more sockets with the server. Each socket can have it's own event listeners registered for responses received from the server.

	var socket = Nakama.create_socket_from(client)
	socket.connect("connected", self, "_on_socket_connected")
	socket.connect("closed", self, "_on_socket_closed")
	socket.connect("received_error", self, "_on_socket_error")
	yield(socket.connect_async(session), "completed")
	print("Done")

func _on_socket_connected():
	print("Socket connected.")

func _on_socket_closed():
	print("Socket closed.")

func _on_socket_error(err):
	printerr("Socket error %s" % err)

Contribute

The development roadmap is managed as GitHub issues and pull requests are welcome. If you're interested to improve the code please open an issue to discuss the changes or drop in and discuss it in the community forum.

Run Tests

To run tests you will need to run the server and database. Most tests are written as integration tests which execute against the server. A quick approach we use with our test workflow is to use the Docker compose file described in the documentation.

Additionally, you will need to copy (or symlink) the addons folder inside the test_suite folder. You can now run the test_suite project from the Godot Editor.

To run the tests on a headless machine (without a GPU) you can download a copy of Godot Headless and run it from the command line.

To automate this procedure, move the headless binary to test_suite/bin/godot.elf, and run the tests via the test_suite/run_tests.sh shell script (exit code will report test failure/success).

cd nakama
docker-compose -f ./docker-compose-postgres.yml up
cd ..
cd nakama-godot
sh test_suite/run_tests.sh

Make a new release

To make a new release ready for distribution, simply zip the addons folder recursively (possibly adding CHANGELOG, LICENSE, and README.md too).

On unix systems, you can run the following command (replacing $VERSION with the desired version number). Remember to update the CHANGELOG file first.

zip -r nakama-$VERSION.zip addons/ LICENSE CHANGELOG.md README.md

License

This project is licensed under the Apache-2 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].