Pure Dart Client for Nakama Server 🌟🥰🤩

Overview

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

Comments
  • Detecting socket disconnect

    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?

    enhancement 
    opened by devpro555 11
  • Organize generated gRPC client

    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)
    opened by obrunsmann 7
  • Add Chat feature

    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.

    opened by fbernaly 6
  • Authentication suddenly stops working

    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;
      }
    
    
    opened by AxiatCode 6
  • Add readStorageObject method

    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.

    opened by aminalaee 4
  • Add listLeaderboardRecords method

    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

    opened by aminalaee 3
  • Issue with serverKey

    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

    bug 
    opened by lchenneberg 3
  • The rpc method in the websocket client returns null

    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
    opened by lchenneberg 2
  • Upgrading swagger & chopper client

    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.

    good first issue 
    opened by obrunsmann 1
  • Facebook friends import feature support in authenticate with facebook method

    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."

    enhancement good first issue 
    opened by ZaheerFaisal 1
  • onMatchData doesn't trigger when sending data

    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 ...

    opened by lchenneberg 1
  • Both  listLeaderboardRecords and listLeaderboardRecordsAroundOwner Functions can't return full list.  even if ownerIds is null

    Both  listLeaderboardRecords and listLeaderboardRecordsAroundOwner Functions can't return full list. even if ownerIds is null

    For example:

    listLeaderboardRecords function,

    If ownerId parameter is set to exact user id list, It 's ok to return the correct records.

    But if ownerId is null or [], or just remove this parameter, It return empty leaderboard records!

    opened by okworld26 6
Releases(v1.0.0-dev.2)
  • v1.0.0-dev.2(Nov 30, 2022)

  • v1.0.0-dev.1(Nov 30, 2022)

    • Changed License from MIT to Apache 2.0
    • Breaking: Refactored the SDK to use own models instead of returning the underlaying Protobuf objects
    • Most of the functionality added to achieve a stable release:
      • Authentication (Session refresh, missing drivers, linking and unlinking)
      • Leaderboard
      • Friends & Groups
      • Notifications
      • Tournaments
      • Matches
    Source code(tar.gz)
    Source code(zip)
  • v0.1.6(Aug 11, 2022)

    • Full storage object support 🎉
    • Breaking readStorageObject() returns now Future<StorageObject?> instead of Future<StorageObject>. Future resolves with null in case there was no element found with given key.
    • Adds submitting and listing leaderboard records (more WIP)
    • Adds updateAccount() method
    • Bumps dependencies and API client to latest versions
    Source code(tar.gz)
    Source code(zip)
  • v0.1.5(May 26, 2022)

  • v0.1.5-dev.2(May 25, 2022)

  • v0.1.5-dev.1(May 24, 2022)

    First draft on chat feature. Not yet full covered with tests, feel free to check it out and report any issues on https://github.com/obrunsmann/flutter_nakama/issues/13

    Source code(tar.gz)
    Source code(zip)
  • v0.1.4(Mar 4, 2022)

  • v0.1.3(Oct 6, 2021)

  • v0.1.2(Jun 3, 2021)

  • v0.1.1(Jun 3, 2021)

  • v0.1.0(Jun 2, 2021)

Owner
Oliver Brunsmann
CTO @kernwerk
Oliver Brunsmann
SurrealDB client written in pure dart. auto reconnect, typed functions

SurrealDB Client For Dart & Flutter SurrealDB client for Dart and Flutter. Quick Start import 'package:surrealdb/surrealdb.dart'; void main(List<Stri

Duhan BALCI 10 Dec 18, 2022
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

Trần Thiên Trọng 1 Jan 23, 2022
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

Mark Winckle 58 Dec 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

Andrew Stein 0 Jan 9, 2022
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

Young Monkeys 44 Dec 13, 2022
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

Abd al-Rahman al-Ktefane 5 Dec 25, 2022
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

HiveDB 3.4k Dec 30, 2022
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

HiveDB 3.4k Dec 30, 2022
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

Hugo Delaunay 38 Oct 28, 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

Modestas Valauskas 2 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. Getting Started https://github.com/Shubham-Narkhede/animated_dialog_box/blob/m

Shubham-Narkhede 10 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

Kristiyan Mitev 103 Nov 29, 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. Screenshot Todo show/hide animation Usage You can find the

吴述军 Brant 377 Dec 24, 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

Chip Weinberger 11 Oct 29, 2022
A pure Dart package for working with RDF (resource description framework).

RDFLib A pure Dart package for working with RDF (resource description framework). Features Create triple instances (with data types) Create a graph to

null 5 Dec 15, 2022
A simple set of terminal-based arcade games written in pure Dart.

dartcade A simple set of terminal-based arcade games written in pure Dart. Purpose I was developing some simple 2D UI libraries (such as package:gridd

Matan Lurey 7 Dec 7, 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

Luanzera07 0 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]

Snowball Digital 45 Nov 9, 2022
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

Zino & Co. 3.1k Jan 5, 2023