Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on Unreal 4.27 #6

Closed
mostafabder1 opened this issue Jan 1, 2022 · 6 comments
Closed

Not working on Unreal 4.27 #6

mostafabder1 opened this issue Jan 1, 2022 · 6 comments

Comments

@mostafabder1
Copy link

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?

@Amaratsu
Copy link

Amaratsu commented Jan 3, 2022

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:

PrivateDependencyModuleNames.AddRange(new string[]
{
"SignalR",
}
);
Create a hub connection with the SignalR engine subsystem:

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

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.

Hub->Invoke(TEXT("Add"), 1, 1).BindLambda([](const FSignalRValue& Result) {
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);

@mostafabder1
Copy link
Author

mostafabder1 commented Jan 3, 2022

That’s what i have been doing for 5 days,
But nothing happened
Not even logs tells anything
Even OnConnectionError
And this library is the only for SignalR in UE :(
image

@intelligide
Copy link
Contributor

@mostafabder1 Have you called IHubConnection::Start() after binding the events ?

@mostafabder1
Copy link
Author

Yup, i did multiple debugging in Connection.Cpp , i found that FConnection::Negotiate has been called but the HttpRequest->OnProcessRequestComplete() listner doesn't been called so that never reached FConnection::OnNegotiateResponse
image

@alexhajdu
Copy link

The plugin is definitely working, but strange enough, logs are not. I can confirm that. However, in the debug build, I was able to set break points to see, all is working as expected.
@mostafabder1 Try debug config and break-points

@intelligide
Copy link
Contributor

@mostafabder1 You just need to persist a reference to the connection object somewhere in your code to ensure that the object is not destroyed when the pointer is destroyed. As the functions are asynchronous, the shared pointer deletes the connection object before the negotiation with the server ended if there are no more references to the connection object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants