is-centre / udp-ue4-plugin-win64

A simple UDP communication plugin based on freely available code
MIT License
50 stars 20 forks source link

How to receive String instead of a float? #4

Closed vettorazi closed 3 years ago

vettorazi commented 3 years ago

First of all, thanks for your Plugin. I'm trying to receive data from a UDP stream but instead of receiving ASCII, I just receive a float value. i.e: I am sending abcd and in UE I'm receiving a huge float like this 234123131241414.0 What I'm doing wrong?

vettorazi commented 3 years ago

Hi Aleksei, I could edit the .h and rebuild the UDPData.h. Although the way I changed the UPROPERTY didn't work. UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "UDPCommunication") FString string1 = "testing";

Can you help me?

extall commented 3 years ago

Exactly, that is because by default with basic datatypes like floats and uint8's. In real time communication with MATLAB/Simulink via Simulink Desktop Realtime toolbox this is what you want, and this is the main use case for this plugin. However, it should also be possible to send/receive strings as well, it's just that sending/receiving sides should be able to pack and unpack this type of data (i.e., serialize it to the UDP packet payload and unserialize it later). My suggestion is to try to figure out how something like this is done here: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/25008-communication-between-ue4-and-a-python-udp-server If you can later also suggest what changes should be done in this plugin to accommodate the above stated functionality, it would be a welcome contribution.

extall commented 3 years ago

It most likely never returns true because the socket does not receive anything. Please check your connection/routing/etc. Use something like Wireshark (https://www.wireshark.org/) to debug. The code after the branch statement (Get String) will not work either, because this is not the way you get data via this plugin. The plugin itself is intended more for sending simple datatypes such as double values or plain bytes, in real time. It is possible to send strings as well, but it is not well supported by default, you will need to change the data structure, its serialization, etc. within the plugin's C++ code. So, for more complex communication tasks I recommend using something like https://github.com/getnamo/socketio-client-ue4