Coder Social home page Coder Social logo

frozenstorminteractive / unreal-signalr Goto Github PK

View Code? Open in Web Editor NEW
38.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

unreal-signalr's People

Contributors

intelligide avatar tbureck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

unreal-signalr's Issues

Unreal project won't open after enabling the SignalR plugin.

I downloaded and pasted the source code in the plugin's folder and enabled it in the editor(UE 4.26.2), but after restarting the project, it would keep asking to build the code from source. But building the project from VS is giving me the same error. See the attachment.
image

How to support MessagePack?

For example, I want to use this with PlayFab GBaaS: How would I add support for MessagePack? Why the limitation, currently?

OnNegociateResponse never called

Unreal 4.27.2

This is related to issue #10 and issue #6 because they both mention the same problem : OnNegociateResponse is never called in the provided code. refer to issue #6 for screenshots. I've been able to reproduce both issues. #10 happens with https connexion while #6 is easier to reproduce with http connexions

using a shared pointer with bindSP in connexion.cpp doesn't work, as the delegate is apparently never called. I tried changing it to bindRaw and it works, but the object the delegate is called on is a different one that has no populated attributes, so it ends up crashing too.

I don't know how to proceed to fix this, other than maybe change the way the negociation step happens. either by using a raw pointer or a lambda ?

Not working on Unreal 4.27

there is nothing happens in unreal side when connecting to SignalR URL
also there is no printing logs
i tried Hub->On, OnConnected, OnConnectionError but not working
any help? or Documentation?

Packaging error for Android ASTC / Client

Hey devs, I've got a packaging error for Android ASTC (arm64).

UATHelper: Packaging (Android (ASTC)):     15 errors generated.
PackagingResults: Error: invalid application of 'sizeof' to an incomplete type 'FSignalRValue'
PackagingResults: Error: no type named 'ConstPointerType' in 'TCallTraits<FSignalRValue>'
PackagingResults: Error: no type named 'ConstInitType' in 'TTypeTraits<FSignalRValue>'
PackagingResults: Error: no type named 'KeyInitType' in 'TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false>'
PackagingResults: Error: no type named 'ElementInitType' in 'TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false>'
PackagingResults: Error: no type named 'KeyType' in 'TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false>'
PackagingResults: Error: no type named 'KeyType' in 'TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false>'
PackagingResults: Error: no member named 'bAllowDuplicateKeys' in 'TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false>'
PackagingResults: Error: no type named 'KeyInitType' in 'TSortableMapBase<FString, FSignalRValue, FDefaultSetAllocator, TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false> >'
PackagingResults: Error: no type named 'KeyConstPointerType' in 'TSortableMapBase<FString, FSignalRValue, FDefaultSetAllocator, TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false> >'
PackagingResults: Error: invalid range expression of type 'const TMap<FString, FSignalRValue, FDefaultSetAllocator, TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false> >'; no viable 'begin' function available
PackagingResults: Error: no member named 'Add' in 'TMap<FString, FSignalRValue, FDefaultSetAllocator, TDefaultMapHashableKeyFuncs<FString, FSignalRValue, false> >'
PackagingResults: Error: implicit conversion of nullptr constant to 'bool' [-Werror,-Wnull-conversion]
PackagingResults: Error: implicit conversion of nullptr constant to 'bool' [-Werror,-Wnull-conversion]

HTTPS/SSL issues

Hi! I've been pulling my hair over this for a while and thought I'd ask here. Cloned this repository into my project Plugins folder. Everything seems to work OK, but there's an error when negotiating with the signalr hub.

The hub is locally hosted (VS2022 Core WebApp), and works when using a browser with the same url. Both http and https. UE log gives me this error about SSL certificate:

image

Any ideas on how to solve this?

how to subscribe to an event in blueprint

Hello, how to subscribe to an event in the blueprint, I don’t need to send anything, just subscribe to the alarm from the signalr side, I noticed that there is a signalrwrapper, but I didn’t understand how to interact with it, I will be glad for any help

Updates and Blueprints

Hi, I see that you are updating the plugin and it is very encouraging, thank you very much for the work done, can you tell me if the plugin will be updated to version 2.4.2 and later versions, will it also be done for blueprints?

I can't receive messages

I follow the instructions (unreal 4.27), get connected and send messages to the signalr server... but I can't receive message from the server.

Hub = GEngine->GetEngineSubsystem<USignalRSubsystem>()>CreateHubConnection("http://localhost:5084/echoHub");

Hub->On(TEXT("Say")).BindLambda([](const TArray<FSignalRValue>& Arguments) {
    UE_LOG(LogTemp, Warning, TEXT("Message received"));
    });

Hub->OnConnected().AddLambda([this]{
    UE_LOG(LogTemp, Warning, TEXT("Connected"));
});

Hub->OnConnectionError().AddLambda([](const FString Message) {
    UE_LOG(LogTemp, Warning, TEXT("Error: %s"), *Message);
 });

Hub->Start();

I will like to know at least where to debug... because Im not getting anything

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.