Coder Social home page Coder Social logo

frozenstorminteractive / unreal-signalr Goto Github PK

View Code? Open in Web Editor NEW
41.0 5.0 20.0 578 KB

SignalR client for Unreal Engine

License: MIT License

C++ 92.05% C 4.96% C# 2.99%
unreal-engine unreal unreal-engine-4 unreal-engine-5 signalr signalr-client websocket unrealengine ue4 ue5

unreal-signalr's Introduction


Logo
SignalR for Unreal

Dependencies

This plug-in requires Visual Studio and either a C++ code project or a full Unreal Engine source code from GitHub.

This plugin does not support the MessagePack protocol for the moment, only the JSON protocol.

Usage

You can use this plug-in as a project plug-in, or an Engine plug-in:

  • If you use it as a project plug-in, clone this repository into your project's Plugins directory and compile your game in Visual Studio. A C++ code project is required for this to work.

  • If you use it as an Engine plug-in, clone this repository into the Engine/Plugins directory and compile your game. Full Unreal Engine source code from GitHub is required for this.

This plug-in is enabled by default, so no need to enable it in the plug-in browser.

Link the SignalR module to to yours with PublicDependencyModuleNames or PrivateDependencyModuleNames in <YourModule>.build.cs:

PrivateDependencyModuleNames.AddRange(new string[]
{
    "SignalR",
}
);

Create a hub connection with the SignalR engine subsystem:

#include "SignalRModule.h"
#include "IHubConnection.h"

TSharedPtr<IHubConnection> Hub = GEngine->GetEngineSubsystem<USignalRSubsystem>()->CreateHubConnection("https://example.com/chathub");

Bind an event which is fired when the server call it to the client.

Hub->On(TEXT("EventName")).BindLambda([](const TArray<FSignalRValue>& Arguments)
{
    ...
});

Invoke fires an event when the server has finished invoking the method (or an error occurred). In addition, the event can receive a result from the server method, if the server returns a result.

Hub->Invoke(TEXT("Add"), 1, 1).BindLambda([](const FSignalRInvokeResult& Result)
{
    if (!Result.HasError())
    {
        UE_LOG(LogTemp, Warning, TEXT("The result value is: %d"), Result.AsInt());
    }
});

Unlike the Invoke method, the Send method doesn't wait for a response from the server.

Hub->Send(TEXT("Add"), 1, 1);

Troubleshooting

Nothing happens when connecting to SignalR URL

Keep a reference to your connection with a shared pointer. If you don't do this, the connection object will be destroyed and therefore won't work.

Remember that the function IHubConnection::Start is asynchronous. When you send data after calling the function, the connection may not be complete (the data to be sent are kept on hold)

Negotiate failed with status code 307

LogSignalR: Error: Negotiate failed with status code 307

Redirections are not yet supported. Use IP address or a domain name without redirection.

You can also disable UseHttpsRedirection() in ASP.NET Core.

Peer certificate cannot be authenticated with given CA certificates

The HTTP module does not support self-signed certificates. The dotnet development certificate is not recognized by Unreal.

You can:

  • use the HTTP protocol (Disable UseHttpsRedirection() in ASP.NET Core)
  • or disable peer verification in Project Settings > Engine > Network > Verify Peer

Disable peer verification in Unreal Project Settings

Contributing

Please see CONTRIBUTING.md for instructions on how to contribute.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Copyright (c) 2020-2022 Frozen Storm Interactive, Yoann Potinet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.