heroiclabs / nakama-godot

Godot client for Nakama server written in GDScript.
Apache License 2.0
608 stars 72 forks source link

Add C# HTML5 export with the .NET client #87

Closed jfaz13 closed 2 years ago

jfaz13 commented 2 years ago

Hello,

Running the sample var session = await client.AuthenticateEmailAsync(email, password) doesn't work in HTML5 export. Works fine in the Windows one. Something similar to the Unity Client needs to be done, making use of Godot's WebSocket API, E.G:

private Godot.WebSocketClient ws;
public override void _Ready()
{
    ws = new Godot.WebSocketClient();
    GD.Print(ws.ConnectToUrl("ws://127.0.0.1:8080/ws-chat/123?name=Hostname", new string[1]{"my-protocol"}, false));
}

Relevant thread: https://gitter.im/heroiclabs/nakama?at=61d6108e82a4667b255f8393

Thank you!

dsnopek commented 2 years ago

I threw together some C# adapter classes that allow the Nakama .NET client to be used in an HTML5 export with Godot:

https://gist.github.com/dsnopek/8aa6c7d06ad8bce867f4faae2664c305

They need to be cleaned up a bit, but they do work in my testing! (See the Example.cs for how to use them.)

The main question is: Do we put those in this repo? Or, do we make a new C#-only repo similar to https://github.com/heroiclabs/nakama-unity that has these classes which developers can install via Nuget?

@docsncode @novabyte Do you guys have any thoughts?

novabyte commented 2 years ago

@dsnopek I think for the moment we can include these files once they've been reviewed as part of this project under some "mono-utils" folder or similar. They can be treated as code snippets until we decide we want to maintain another SDK variation.

dsnopek commented 2 years ago

Ok, sounds good, thanks! I've cleaned up the code a bit, and made PR #102 which puts the classes into a 'mono-utils' directory