Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FrozenStormInteractive/Unreal-SignalR
SignalR client for Unreal Engine
https://github.com/FrozenStormInteractive/Unreal-SignalR
signalr signalr-client ue4 ue5 unreal unreal-engine unreal-engine-4 unreal-engine-5 unrealengine websocket
Last synced: about 1 month ago
JSON representation
SignalR client for Unreal Engine
- Host: GitHub
- URL: https://github.com/FrozenStormInteractive/Unreal-SignalR
- Owner: FrozenStormInteractive
- License: mit
- Created: 2020-03-23T21:13:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-20T13:21:07.000Z (7 months ago)
- Last Synced: 2024-08-02T16:31:07.025Z (4 months ago)
- Topics: signalr, signalr-client, ue4, ue5, unreal, unreal-engine, unreal-engine-4, unreal-engine-5, unrealengine, websocket
- Language: C++
- Homepage:
- Size: 564 KB
- Stars: 41
- Watchers: 5
- Forks: 20
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: License.txt
Awesome Lists containing this project
- awesome-unreal - Unreal-SignalR - SignalR client for Unreal Engine. (Networking)
README
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 `.build.cs`:
```cs
PrivateDependencyModuleNames.AddRange(new string[]
{
"SignalR",
}
);
```Create a hub connection with the SignalR engine subsystem:
```cpp
#include "SignalRModule.h"
#include "IHubConnection.h"TSharedPtr Hub = GEngine->GetEngineSubsystem()->CreateHubConnection("https://example.com/chathub");
```Bind an event which is fired when the server call it to the client.
```cpp
Hub->On(TEXT("EventName")).BindLambda([](const TArray& 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.
```cpp
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.
```cpp
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](/Docs/static/img/Unreal-DisablePeerVerification.png)
## Contributing
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute.
## License
This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details.
```
Copyright (c) 2020-2022 Frozen Storm Interactive, Yoann Potinet
```