Pure Dart Client for Nakama Server 🌟🥰🤩

Last update: Aug 11, 2022

Nakama Flutter Client 🤩 🎮 🌍 🛰

Nakama is an open-source scalable game server. This is a Flutter client for Nakama written in pure dart and supports cross platform gaming on iOS, Android, Web and more.

GitHub issues GitHub last commit Pub Version


🚦 Current Status

Almost all basic functions which are necessary to start playing around with Nakama are ready to use. Please feel free to give your feedback with creating an issue. I am currently working on getting a 100 % coverage with this SDK.

🚀 Getting Started

1. Setup Nakama Server

You need a Nakama instance for developing. I suggest setting up Nakama with Docker Compose. You find a tutorial here: Install Nakama with Docker Compose and here Installation & Setup.

2. Add flutter_nakama to pubspec.yaml.

name: your_game
dependencies:
    flutter:
        sdk: flutter
    flutter_nakama: ^0.1.0

3. Create nakama base client

final client = getNakamaClient(
  host: '127.0.0.1',
  ssl: false,
  serverKey: 'defaultkey',
  grpcPort: 7349, // optional
  httpPort: 7350, // optional
);

4. Use the SDK

For example start with logging into an user account:

final session = await getNakamaClient().authenticateEmail(
    email: '[email protected]',
    password: 'mySecurePassword!',
);

print('Hey, you are logged in! UserID: ${session.userId}');

Documentation

Flutter SDK Docs: https://flutter-nakama.gitbook.io

Nakama Docs: https://heroiclabs.com/docs

GitHub

https://github.com/obrunsmann/flutter_nakama
Comments
  • 1. Detecting socket disconnect

    Hello,

    I am running into an issue where the user gets disconnected from the socket either due to idle time or server error. I am not able to find a way to detect that the socket connection is lost and make an attempt to reconnect. Can you let me know how and where to listen for socket disconnect event and can I simply reconnect using the same NakamaWebsocketClient.init method at that point?

    Reviewed by devpro555 at 2021-10-07 22:37
  • 2. Organize generated gRPC client

    • [x] Publish model files from the library → No imports of the .pb.dart files should be necessary from outside the package
    • [x] Remove unused generated files (some unit test files have been generated as well from google/protobuf package)
    Reviewed by obrunsmann at 2021-06-03 06:08
  • 3. Add Chat feature

    Added Chat feature as explained here: https://heroiclabs.com/docs/nakama/client-libraries/unity/#chat Added methods:

    • joinChannel
    • sendMessage
    • listChannelMessages
    • updateMessage and added a StreamController to listen to incoming messages.

    Moved nakama_client_stub.dart to a subfolder with implementations for io and js, to allow exposing NakamaRestApiClient and NakamaGrpcClient if devs prefer to instantiate one of them directly without forcing them to use getNakamaClient.

    Reviewed by fbernaly at 2022-04-01 18:49
  • 4. Authentication suddenly stops working

    Authentication with Nakama server using SDK is not working and throwing this error in response:

    flutter: gRPC Error (code: 2, codeName: UNKNOWN, message: HTTP/2 error: Connection error: Connection is being forcefully terminated. (errorCode: 10), details: null, rawResponse: null)

    Future<bool> authenticateWithCustomAsync(
        BuildContext context, LoginDetails loginDetails) async {
      bool result = false;
      try {
        await getNakamaClient()
            .authenticateCustom(
                id: loginDetails.socialUserID!,
                username: loginDetails.socialUserName!.replaceAll(" ", ""))
            .then((session) {
          nakamaSession = session;
          result = true;
        });
      } catch (e) {
        hideLoading(context);
        print(e.hashCode);
        print(e.toString());
        result = false;
      }
    
    
    Reviewed by AxiatCode at 2021-09-01 10:08
  • 5. Add readStorageObject method

    Should be reviewed after #35.

    Adds readStorageObject method with tests. I followed the pattern already done for writeStorageObject which is a bit different from official client, as it will allow creating and reading one object with each call. Hence this method is readStorageObject not readStorageObjects.

    Reviewed by aminalaee at 2022-06-08 08:26
  • 6. Add listLeaderboardRecords method

    This adds listLeaderboardRecords method to the client.

    This is my first PR to a Flutter/Dart project, so there might be some obvious points I'm missing.

    Part of https://github.com/obrunsmann/flutter_nakama/issues/7

    Reviewed by aminalaee at 2022-06-07 12:56
  • 7. Issue with serverKey

    Hello,

    Can you push a quick fix on the library?

    String serverKey='defaultkey',

    this.serverKey = 'Basic ${base64Encode('$serverKey:'.codeUnits)}';

    https://github.com/obrunsmann/flutter_nakama/blob/64bd5c5219fb1d3d0cc8dd110246141b0e3965e6/lib/src/nakama_client/nakama_grpc_client.dart#L71

    Reviewed by lchenneberg at 2021-09-30 21:34
  • 8. The rpc method in the websocket client returns null

    Hello, I'm facing some issues with rpc.

    I try to call the rpc async method from the websocket client the Future returns null on every call; In the server logs I can see that the method has been called.

    Can you get a look and tell me what I am doing wrong?

    Screen Shot 2021-07-17 at 1 06 45 AM Screen Shot 2021-07-17 at 1 06 14 AM Screen Shot 2021-07-17 at 1 06 04 AM Screen Shot 2021-07-17 at 1 05 34 AM
    Reviewed by lchenneberg at 2021-07-17 05:11
  • 9. Upgrading swagger & chopper client

    There is a new swagger file available for nakama's REST API: https://github.com/heroiclabs/nakama/blob/master/apigrpc/apigrpc.swagger.json

    Problem: There some chopper updates which are currently making it impossible to just generate a new client. For some reason all new generated methods getting prefixed with the path which should be a chopper config.

    Bildschirmfoto 2022-03-31 um 14 23 58

    When I started working on this project I heavily thought about using chopper or writing REST models by hand. Supporting REST + gRPC in parallel for this package is some kind of a challenge. Now unfortunately there is the downside of this approach, that needs a fix for the chopper config.

    I think I would be able to check this on weekend, but cannot promise within just a few hours here.

    Reviewed by obrunsmann at 2022-03-31 12:26
  • 10. Facebook friends import feature support in authenticate with facebook method

    It will be great to have this feature and it will be easy to import facebook friends into nakama friend's graph.

    As described here:

    "You can optionally import Facebook friends into Nakama's friend graph when authenticating. To do this, set import to true."

    Reviewed by ZaheerFaisal at 2021-08-29 15:26
  • 11. onMatchData doesn't trigger when sending data

    hello,

    I've tried on a new project and I was not able to receive the data listening on onMatchData. I can see the server receive the input.

    Could be many reason: The data is not sent to the client The client doesn't receive the data The stream is not working ...

    Reviewed by lchenneberg at 2021-07-14 04:35
  • 12. Overview: Missing features

    This issue is an overview to track progress of this Flutter SDK.

    General SDK Features

    Modules

    Authentication

    User Accounts

    Remote procedure calls (gRPC)

    Friends

    Status & Presence

    Groups

    Chat

    Created in #31, double check needed if all methods are supported.

    Matches

    Parties

    Leaderboards

    Tournaments

    Notifications

    Reviewed by obrunsmann at 2022-07-05 19:58

Related

Socketio dart server and client - Full Socket.io implementation using Dart Lang
Socketio dart server and client - Full Socket.io implementation using Dart Lang

Getting Started Step 1: Run dart_server.dart Step 2: Android Emulator has proble

Jan 23, 2022
A streaming client for the Komga self-hosted comics/manga/BD server targeting Android/iOS written in Dart/Flutter
A streaming client for the Komga self-hosted comics/manga/BD server targeting Android/iOS written in Dart/Flutter

Klutter A streaming client for the Komga self-hosted comics/manga/BD server targeting Android/iOS written in Dart/Flutter Background This is a project

Aug 7, 2022
Mildly encrypted package - An encryption client & server for Dart Native + mobile platforms.

TODO: Put a short description of the package here that helps potential users know whether this package might be useful for them. Features TODO: List w

Jan 9, 2022
a flutter socket client sdk for ezyfox-server
a flutter socket client sdk for ezyfox-server

ezyfox-server-flutter-client flutter client for ezyfox server Architecture Offical documentation https://youngmonkeys.org/ezyfox-flutter-client-sdk/ P

Jul 11, 2022
Powerful, helpfull, extensible and highly customizable API's that wrap http client to make communication easier with Axelor server with boilerplate code free.
Powerful, helpfull, extensible and highly customizable API's that wrap http client to make communication easier with Axelor server with boilerplate code free.

flutter_axelor_sdk Powerful, helpful, extensible and highly customizable API's that wrap http client to make communication easier with Axelor server w

Nov 12, 2021
Lightweight and blazing fast key-value database written in pure Dart.
Lightweight and blazing fast key-value database written in pure Dart.

Fast, Enjoyable & Secure NoSQL Database Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask. Documenta

Aug 9, 2022
Lightweight and blazing fast key-value database written in pure Dart.
Lightweight and blazing fast key-value database written in pure Dart.

Fast, Enjoyable & Secure NoSQL Database Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask. Documenta

Aug 15, 2022
A simple day / night switcher widget made in pure Dart.
A simple day / night switcher widget made in pure Dart.

DayNightSwitcher Just a simple simple day / night switcher widget made in pure Dart. It allows you to quickly show a beautiful dark mode switcher widg

Jul 14, 2022
Dart port of FormCoreJS: A minimal pure functional language based on self dependent types.

FormCore.js port to Dart. So far only the parser and typechecker have been ported i.e. the FormCore.js file in the original repo. (Original readme fro

Jan 28, 2022
Animated dialog box - A pure dart package for showing animated alert box.
Animated dialog box - A pure dart package for showing animated alert box.

animated_dialog_box A pure dart package for showing animated alert box. Getting Started https://github.com/Shubham-Narkhede/animated_dialog_box/blob/m

Jul 24, 2022
A pure Dart utility library that checks for an internet connection by opening a socket to a list of specified addresses, each with individual port and timeout. Defaults are provided for convenience.

data_connection_checker A pure Dart utility library that checks for an internet connection by opening a socket to a list of specified addresses, each

Aug 8, 2022
This project was writed with pure dart code,which means it's support both iOS and Android.
This project was writed with pure dart code,which means it's support both iOS and Android.

This project was writed with pure dart code,which means it's support both iOS and Android. Screenshot Todo show/hide animation Usage You can find the

Aug 8, 2022
DartMeltySoundFont - a SoundFont synthesizer (i.e. '.sf2' player) written in pure Dart

DartMeltySoundFont DartMeltySoundFont is a SoundFont synthesizer (i.e. '.sf2' player) written in pure Dart. It is a port of MeltySynth (C#, MIT Licens

May 1, 2022
Dart-com-Shelf - Web server básico feito com dart e shelf, configurações de rotas e conexão com mysql.

A server app built using Shelf, configured to enable running with Docker. This sample code handles HTTP GET requests to / and /echo/<message> Running

Jan 3, 2022
A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package. Built after react apollo

Flutter GraphQL Table of Contents Flutter GraphQL Table of Contents About this project Installation Usage GraphQL Provider [Graphql Link and Headers]

Jul 22, 2021
A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.

GraphQL Flutter ?? Bulletin See the v3 -> v4 Migration Guide if you're still on v3. Maintenance status: Low. Follow #762 for updates on the planned ar

Aug 8, 2022
Vrchat mobile client - VRChat Unofficial Mobile Client For Flutter
Vrchat mobile client - VRChat Unofficial Mobile Client For Flutter

VRChatMC VRChatの非公式なAPIを利用したVRChatのモバイルクライアント Flutterで作成されたシンプルなUIが特徴的です iosビルドは

Aug 4, 2022
Mysql.dart - MySQL client for Dart written in Dart

Native MySQL client written in Dart for Dart See example directory for examples

Jul 30, 2022
Interview questions and answers for preparation, built in pure flutter also have CI implementation for learning.
Interview questions and answers for preparation, built in pure flutter also have CI implementation for learning.

toughest An app for interview preparation. Unique animations. More than 100 questions and answer. Good UI. Featured in many websites. For Vietnam user

Jul 16, 2022