Giter Site home page Giter Site logo

Comments (8)

CheaterScript avatar CheaterScript commented on June 12, 2024 1

Thank you for your response. My question wasn't very clear. The main issue I'm facing is not knowing how to send a MessageList through the Emit method. I've attempted to implement an interface myself, and it looks like this:

void USocketIOClientComponent::EmitMessages(const FString& EventName, const TArray<TSharedPtr<FJsonValue>>& Messages, const FString& Namespace)
{
	if (Messages.Num() <= 0)
	{
		//Set the message is not null
		TSharedPtr<FJsonValue> JsonMessage = MakeShareable(new FJsonValueNull);

		NativeClient->Emit(EventName, JsonMessage, nullptr, Namespace);
		return;
	}

	sio::message::list* MessageList = new sio::message::list();

	for (int i = 0; i < Messages.Num(); i++)
	{
		MessageList->push(USIOMessageConvert::ToSIOMessage(Messages[i]));
	}

	NativeClient->EmitRaw(EventName, *MessageList, nullptr, Namespace);

	delete MessageList;
}

I'm not sure if there's already a solution like this in the plugin, but my current implementation seems to meet my needs.
Thank you for all your assistance.

from socketioclient-unreal.

getnamo avatar getnamo commented on June 12, 2024

Can you point to socket.io protocol documentation of your requested feature?

from socketioclient-unreal.

CheaterScript avatar CheaterScript commented on June 12, 2024

I haven't found an exact example, but it should be similar to the image below:
image
This is what the JavaScript client looks like after encoding:
image

from socketioclient-unreal.

CheaterScript avatar CheaterScript commented on June 12, 2024

image

from socketioclient-unreal.

getnamo avatar getnamo commented on June 12, 2024

This looks like just a multiparam message which is supported via second param on function, see e.g. https://github.com/getnamo/SocketIOClient-Unreal?tab=readme-ov-file#emit-with-callback and https://github.com/getnamo/SocketIOClient-Unreal?tab=readme-ov-file#binding-events-to-functions

Or in c++ via

void OnNativeEvent( const FString& EventName,

I generally recommend wrapping your multiparam into a single param as it isn't limited to function callback signature.

from socketioclient-unreal.

getnamo avatar getnamo commented on June 12, 2024

It seems I misunderstood, I do believe this variant:

void EmitNative(const FString& EventName,

Does the same, but if does not, feel free to open a pull request and I can merge the feature to mainline.

from socketioclient-unreal.

CheaterScript avatar CheaterScript commented on June 12, 2024

I tested the method above and didn't get the expected result:

image

The correct result should be:

["call","foo","bar"]

Implementing EmitMessagesWithCallback seems to be quite complex, and I'm not very proficient in C++. I'm worried that I might introduce bugs and may not be able to provide a fully functional PR.

from socketioclient-unreal.

getnamo avatar getnamo commented on June 12, 2024

Interesting, it does seems like the plugin is missing the implementation then. If you open a pull request with your current implementation, I'll apply patches to it to fit other methods before merging; it will give me a base scaffold to apply the rest of the functionality.

from socketioclient-unreal.

Related Issues (20)

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.