Hey guys i have a question. For example i have different channels in SocketIO like CHannel 1 Channel 2 etc. is it possible to connect to different channels with this plugin? If so then let me please know where to find this function
Thanks
Hey guys i have a question. For example i have different channels in SocketIO like CHannel 1 Channel 2 etc. is it possible to connect to different channels with this plugin? If so then let me please know where to find this function
Thanks
The plugin supports socket.io namespaces. When you send a message or bind an event you specify the namespace which by default is just ā/ā. Changing that to your namespaces should do what youāre trying to achieve. See https://github.com//socketio-client-ue4 readme for full documentation.
Now also available on the marketplace for free: Socket.IO Client in Code Plugins - UE Marketplace. Currently available for 4.19, Marketplace 4.20 build pending.
Anybody on here who can possibly answer a question about why i only get āSIOJsonValueā printed to screen when my message from the server says something different?
I basically just want to get the server message printing correctly into Unreal and then be able to access the X: value and the Y:value in the message. Iāve added images below to show my setup.
this is how i am binding the event:
This is how i am just trying to print the message to screen and log:
This is the output that unreal is displaying:
This is the message that my server is sending out:
I assume the problem is the āget display nameā function. Apologies if this is a really simple obvious question, but any pointers as to the problem and how to isolate the X and Y values from the message would really help me out.
Thanks,
Get Display Name is a built in function in the unreal engine which prints the UObjects name. What youāre looking for is Encode Json or AsString(SIOJsonValue), details about this behavior is documented here: https://github.com//socketio-ā¦ing-json-value
Regarding decoding responses beyond debug printing I encourage you to read this section in the documentation readme: https://github.com//socketio-ā¦ding-responses. In general the most efficient way to encode/decode values from server is to have Json Object value e.g. {āxā:5, āyā:6"} on the server side and build a custom c++ or blueprint struct that matches that format, then use the As Object and Json Object to Struct calls with a member variable of your struct type passed in. After that call has been made your member variable will be filled with the received values.
Thatās great. Thanks for the fast response. I think i need to assess how i send these messages in, but for now i can use a simple split function to isoltae the correct part of the message. Thanks.
Welcome. Keep in mind that youāll get most mileage out of the plugin by using Json Objects. You donāt necessarily need structs, but if you do something as simple as
//in your server code where you send your data
//make a temp object
var responseObject = {}
//fill fields
responseObject.x = 3;
responseObject.y = 5;
//emit the response
socket.emit('test5', responseObject);
It will allow you to decode your data very easily via either manual bp graphs
https://i.imgur.com/DuMs3Hu.png
or auto-struct fills
https://i.imgur.com/yWbJxbf.png
Leading to consistent decoding behavior. NB: In both examples *ResponseXY *is a Vector2D struct type provided by the engine. Since we passed in a json object with an āxā and a āyā property on it, these match the names of the struct properties of a *Vector2D *and will correctly fill when using the Json Object to Struct conversion.
Thank you for posting the example. Iāll try it the way you suggest. Many many thanks!
So i followed the advice to use the code in my server and it works great. BUT. How can i get the actual value that is being sent for x and y? I tried
var responseObject = {}
responseObject.x = responseObject.value;
responseObject.y = responseObject.value;
But this just returns an āUndefinedā value for x and y. Thank you if you can help!
Thatās a javascript question consider revising documentation here: JavaScript Tutorial.
To answer your problem, this largely will depend on how you have your values captured and encoded. Find what sends your x and y, store them in a var (or optimally bypass this step), and set those vars to responseObject.x.
The specific reason youāre getting undefined here is because youāve created a javascript object via
var responseObject = {}
and then you try to set itās .x property value to the contents of itās .value property, but this hasnāt been defined before that line.
Hello. Iām new to this wonderful plugin, so Iād like to know if itās suitable for my needs.
I have two apps (one UE4/HTML5 and the other written in WebGL) on my webserver and I want them to communicate. I donāt think they can communicate directly, (correct me if Iām wrong), but they can indirectly by a common interface.
As far as I understood, my idea is to run a NodeJs server as the one provided in the example Chat project, with the feature to act as a bridge between the two apps.
Every time one app sends a message to this server, it automatically send it to the other app, and viceversa.
My questions:
Thank you.
How you connect after you deploy the app I have been trying I change the URL for the deployed on with the port and is not connecting do you have any idea why? Im using https://socket-chat-example-bawzpjpxoy.now.sh/:433
Iām not aware of any UE4 code plugin working with HTML5. If there is documentation on how to get that working Iād be interested to see it. The plugin so far supports Windows and Linux platforms, but itās open source so if any contributors get something working, consider making a pull request and Iāll include it.
Your best bet at this time would probably to use inbuilt UE4 get/post html commands.
āāāāāāhttps isnāt currently supported (use http) due to a bug in the underlying library which requires OpenSSL to be compiled in and use two different paths based on endpoints. Issue is currently tracked here https://github.com//socketio-client-ue4/issues/39
Hello,
Iām trying to implement this plugin with a python server also using socketio. Iām able to connect to the server and emit a message but when a try to receive from the server, UE keep crashing.
I havenāt been able to find a solution to my problem.
**Error in UE editor **:
Log file
As I understand it, I couldnāt bind an event. I couldnāt find whyā¦
Here is my server code (python 3.7)
from aiohttp import web
import socketio
from colorama import init, Fore
init(autoreset=True)
sio = socketio.AsyncServer()
app = web.Application()
sio.attach(app)
#sio.manager.set_server
async def index(request):
with open('index.html') as f:
return web.Response(text=f.read(), content_type='text/html')
@sio.on('connect', namespace="/")
def connect(sid, env):
print(Fore.RED + "connect ", sid)
@sio.on('test', namespace="/")
async def message(sid, data):
print(Fore.GREEN + "message << ", data)
await sio.emit('reply', "Hi i'm the server", sid)
@sio.on('disconnect', namespace="/")
def disconnect(sid):
print(Fore.RED + 'disconnect', sid)
#app.router.add_static('/static', 'static')
app.router.add_get('/', index)
if __name__ == '__main__':
web.run_app(app)
**Blueprints
Does anyone have an idea on how to solve this?
Thank you,
It looks like your reply is an array (āHi iām the serverā, sid])
await sio.emit('reply', "Hi i'm the server", sid)
out of curiosity does it crash if you remove the last variable?
await sio.emit('reply', "Hi i'm the server")
have you tried embedding the sid response in an array? e.g.
await sio.emit('reply', "Hi i'm the server", str(sid]))
It may be that the function AsString is failing in detecting array SIOJsonValues. Iāve opened an issue on the plugin here: https://github.com//socketio-client-ue4/issues/102 for this problem, feel free to continue the discussion there.
Hi, this plugin need some any extra install?
Installed from marketplace, tryed the client sample, but not connetcting to server, donāt get any error.
Tryed from pc and android too. The server is run by another phone (work because can connect, send data with another client app).
Ip and port is good.
Created exe, added to firewall exception, still not work.
Packaged to android phone (android 7), not connect to the server.
4.20.3 UE version.
Any idea?
Android is not yet supported, only windows and linux. Also make sure youāre using http not https. See https://github.com//socketio-client-ue4-example for example documentation.
Good day, how i can connect to dynamicly created room, can you explain?
From a quick scan of the feature, it appears to be server based.
Follow e.g. psitsmike.com - psitsmike Resources and Information. and node.js - Dynamic rooms in Socket.io - Stack Overflow to implement it on the server. On the client youād only need an emit call to switch to the new room and the server handles the switch, in the stack overflow answer the server then emits a message back to the client to do any room update logic (in that example āupdateroomsā).
Good day, itās mean on server side i wrote emit logic for connect new room and than āOn Eventā i can get message from server?