Closed mdblabs closed 1 year ago
use ConnectWithParams
https://github.com/getnamo/SocketIOClient-Unreal/blob/master/Source/SocketIOClient/Public/SocketIOClientComponent.h#L180C7-L180C24
specify your address and port in the FSIOConnectParams
struct (defined here: https://github.com/getnamo/SocketIOClient-Unreal/blob/2d1979cebe0868c161f55fdbb68f8282f0809c3a/Source/SocketIOClient/Public/SIOMessageConvert.h#L18) and pass it in.
Thank you @getnamo for your answer. Unfortunately Unreal Engine crashes when executing ConnectWithParams. Here is my code, as suggested:
this->IOSocket = CreateDefaultSubobject<USocketIOClientComponent>(TEXT("IOSocketClient"));
FSIOConnectParams ConnectParams;
ConnectParams.AddressAndPort = TEXT("http://127.0.0.1:8080");
this->IOSocket->ConnectWithParams(ConnectParams);
Seems that it crashes on NativeConnect method, after the wrapper call. Any suggestion?
Bummer, what does the crash log complain about?
I've traced it. Here is the error:
appError called: Assertion failed: IsValid() [File:Runtime/Core/Public/Templates/SharedPointer.h] [Line: 1139]
And it fails on SocketIOClientComponent.cpp, when calling NativeClient.IsValid():
void USocketIOClientComponent::ClearCallbacks()
{
if (NativeClient.IsValid())
{
UE_LOG(LogTemp, Warning, TEXT("====== NativeClient->ClearAllCallbacks(); ====="));
NativeClient->ClearAllCallbacks();
}
}
Means your native client doesn't have a valid pointer. How are you using your component? Constructed as a default param on an actor or another way?
Means your native client doesn't have a valid pointer. How are you using your component? Constructed as a default param on an actor or another way?
Hi, you were right. I was constructing it on the GameBase constructor. Now call is OK. Problem now is no connection, which I think is related to issue #363 and #383?
I'll close this and I'll try to collaborate on the others. Thanks!
Hi!
I'm migrating my code to new UE5.3. I managed to compile latest plugin version, not without issues related to #383, #387, #380... and so on.
Anyway, I compiled it just fine. The issue started when migrating my UE4.27 code. Seems like SocketIO client API just changed. Now USocketIOClientComponent class doesn't have "AddressAndPort" attribute. This is included in URLParams structure.
But, initiating it as:
this->IOSocket = CreateDefaultSubobject<USocketIOClientComponent>(TEXT("IOSocketClient"))
this->IOSocket->URLParams.AddressAndPort = TEXT("http://localhost:8080");
doesn't seem to work. Checking bIsConnected shows it as false. Also, server doesn't receive any connection (I tested it with localhost, 127.0.0.1, different ports, an so on...).
Trying to pass the Address directly to the Connect method, like:
this->IOSocket->Connect(TEXT("http://localhost:8080"));
crashes Unreal.So, on this new version, how you pass the AddressAndPort structure to the SocketIO client? Documentation in the README.md file is not updated neither.
Context:
Thank you!