Announcement

Collapse
No announcement yet.

[Plugin] Socket.io Client

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • started a topic [Plugin] Socket.io Client

    [Plugin] Socket.io Client

    Socket.io is a performant real-time bi-directional communication library. There are two parts, the server written in node.js and the client typically javascript for the web. There are alternative client implementations and I've used the C++ client library and ported it to UE4.

    For the London is Unreal meetup I made a presentation on the topic of plugins and chose to implement a useful plugin live during the presentation. A socket.io client was chosen as the plugin, which was finished with a basic Connect, Bind, Emit functions and an On event all interfaced through an Actor Component.

    Since 0.4, the plugin is pretty feature complete, let me know what other features you think are missing!

    Contribute
    Currently missing static libs for various platforms see https://github.com/getnamo/socketio-client-ue4/issues

    Download

    Available at: https://github.com/getnamo/socketio-client-ue4/releases

    Resources
    Github Repository - Always contains the latest documentation
    Example UMG Chat Project (contains server and both web and ue4 client)
    How to connect Unreal Engine 4 to local server via WebSocket using blueprints? - By Egor Bogomyakov

    Example project is a functional UMG based chat window place in world showing real-time communication ability of UE4 -> Web/Mobile


    Quick Install & Setup

    1. Download Latest Release
    2. Create new or choose project.
    3. Browse to your project folder (typically found at Documents/Unreal Project/{Your Project Root})
    4. Copy *Plugins* folder into your Project root.
    5. Restart the Editor and open your project again. Plugin is now ready to use.


    How to use - BP Basics

    Add the SocketIO Client Component to your blueprint actor of choice



    Specify your address and port, defaults to localhost (127.0.0.1) at port 3000. Note that since 0.2.0 connect is optional as the component will auto connect unless you disable autoconnect via boolean.



    Call bind for each event you wish the client to subscribe, e.g. 'chat message'. If you expect to receive events, select your component and in the Details pane press the + to add an 'OnEvent' event to your event graph.

    Handle this event for your event types, e.g. printing 'chat message' event strings.



    If you want to send information to the server, emit events on the SocketIO Client Component, e.g. pressing M to emit a 'chat message' string



    Changelist

    See latest changes at https://github.com/getnamo/socketio-client-ue4/releases

    0.7.0
    -Compile fixes for 4.18
    -New Plugin scoped memory architecture for reliable and fast FSocketIONative management. Candidate fixes for #44, #45, #55, #56, #57, #60, and #63. If you were having any of those problems, try the new plugin and give it a good test. Re-open if issues persist. Architecture merged in as f17df08
    -New optional fully plugin-scoped connections which remain even through level transitions. Tick bPluginScopedConnection true and ensure your component before and after use the same PluginScopedId. Unless disconnect is manually called these type of connections will only close on app exit.
    -New OnConnectionProblems callback with verbose signature allowing you to detect when you get disconnected while the socket.io client is still trying to reconnect (default: always trying infinite times). If you wish to change this behavior new parameters have been exposed which control connection attempts and delay.
    -New default toggle bVerboseConnectionLog allows you to quiet your log. Default is true.
    -Blueprint TMap support added! This should be a massive boost to productivity if you used map like data structures. Issue #59 fix merged in f640f63
    -Auto-conversion for As String if string type not supplied. Issue #64 merged in 2b118c4
    -Direct convenience function binds added. This allows you to bind an event or callback to a blueprint function with e.g. String signature only if you know the data type will be a string. See emit with callback section for a list of supported signatures. Issue #65 fix merged in 591c150
    -FSocketIONative now exposed as API. Issue #66 merged in 7e32f70 spotted by GeneralD

    0.6.0
    -Rebased to accomodate #43. You can now put FSocketIONative anywhere with your own allocation structure.
    -'On' event dispatch changed to 'OnEvent'.
    -Candidate fixes for #41, #32, and #38
    -Fixes to underlying library stopping re connection attempts when you close a connection: getnamo/socket.io-client-cpp@3f0cd99

    0.5.2
    -Fixed boolean always returning false #35

    0.5.1
    -Fixed undefined as second emit parameter from server #36

    0.5.0
    -Fixes for disconnecting while communicating with an unreachable server #32
    -Boost updated to 1.62
    -Socket.io-cpp updated to latest master merge
    -misc internal features for tracking and killing lambda threads

    0.4.8
    -UTF8 Support
    -Connection fixes
    -Session ID fix
    -Compile fixes for IWYU changes in 4.15
    -Scaffolds for other platforms from contributors (non-functioning)

    0.4.0
    -Added SIOJson for Blueprint Json construction and conversion, based on VaRest
    -Auto-conversion for nodes
    -Blueprint callbacks and events bound to functions references by function name
    -Conversion of JsonObjects to and from UStructs, including Blueprint UStructs with automatically trimmed long names into readable short names
    -Overloaded EmitNative for all expect UE native data types
    -Much simplified C++ usage based on FJsonValue and FJsonObject including nested binary support (hackery!)
    -and much more

    0.2.6-0.3.4
    -Internal versions for 0.4.0

    0.2.5
    -Change event names and signatures
    -Add wider support for raw message emitting and receiving

    0.2.2-0.2.4
    -raw sio::message support and events

    0.2.1
    -added proper binary send/receive support
    -added functioning onconnect/disconnect events, no longer require
    special events on your server
    -added on namespace connect/disconnect events
    -added on fail event

    0.2.0
    -Update to 4.13
    -Added connect/disconnect signatures (these have to be implemented by
    the server if used)
    -Added C++ lambda binds do e.g.
    BindDataLambdaToEvent([&](const FString& EventName, const FString& EventData) { //your code }, Name, Namespace);
    to use it
    -Bind changed name to BindEvent
    -Added Namespace support
    -Connection runs on background thread (should not be blocking anymore)

    0.1.2
    -Updated compiled dlls and version for 4.12 (no code changes)

    0.1.1
    -First release
    Last edited by getnamo; 08-02-2018, 06:35 AM.

  • replied
    Originally posted by samuelthomson View Post
    Hello again,

    I'm having another issue - SocketIO now works fine in the editor, and I can get the project to build, but when I play the build, the behavior relating to SocketIO doesn't seem to be occurring at all. This is doubly strange, as in the last couple of days I successfully packaged a very similar project and everything worked fine.

    I created this project starting with a blank game project, and then I migrated assets from my old project over to this new project.

    Once again,
    - I've made sure my project is a Blueprints and C++ project, https://allarsblog.com/2015/11/05/co...roject-to-cpp/
    - I've also added "SocketIOClient" to ProjectBuild.cs under PublicDependencyModuleNames
    - Made sure I'm using the right version of SocketIO this time!

    Is there anything else I should check?
    maybe firewall? otherwise open an issue on https://github.com/getnamo/socketio-client-ue4/issues with detailed steps to reproduce (and platform/version used etc). Even better if you can link a minimal project that reproduces issue.

    Some platforms may need a few extra toggles to work: https://github.com/getnamo/socketio-...-ue4#packaging

    Leave a comment:


  • replied
    Hello again,

    I'm having another issue - SocketIO now works fine in the editor, and I can get the project to build, but when I play the build, the behavior relating to SocketIO doesn't seem to be occurring at all. This is doubly strange, as in the last couple of days I successfully packaged a very similar project and everything worked fine.

    I created this project starting with a blank game project, and then I migrated assets from my old project over to this new project.

    Once again,
    - I've made sure my project is a Blueprints and C++ project, https://allarsblog.com/2015/11/05/co...roject-to-cpp/
    - I've also added "SocketIOClient" to ProjectBuild.cs under PublicDependencyModuleNames
    - Made sure I'm using the right version of SocketIO this time!

    Is there anything else I should check?

    Leave a comment:


  • replied
    Originally posted by samuelthomson View Post
    Hello, I've built a project with SocketIO in unreal v4.21.2. I used the version of SocketIO for v4.21 and v4.22. Everything works fine when I run from the editor, but trying to package the project fails with "unknown build error".

    I've attached the output log from Unreal, and the log file from appdata - can you tell me what is going wrong?

    I'm not very used to packaging projects with plugins, so perhaps I've not set things up correctly.

    This is a fairly urgent question for my project, as it has to go live in a couple of days, so thanks in advance for any response.

    Edit:
    - I've made sure my project is a Blueprints and C++ project, https://allarsblog.com/2015/11/05/co...roject-to-cpp/
    - I've also added "SocketIOClient" to ProjectBuild.cs under PublicDependencyModuleNames

    - I installed this plugin by downloading from github, but I also notice there is this: https://launcher-website-prod07.ol.e...cket-io-client
    is that something I need to package this?

    Edit 2: I think I've answered my own question, it seems like I was using SocketIO for Unreal 4.22 instead of the version for Unreal 4.21!
    You may want to look at https://github.com/getnamo/socketio-...ases/tag/1.1.0 release which has 3 versions (4.21-4.23). The marketplace version is just a way for people to help support plugin work, totally optional.

    Leave a comment:


  • replied
    Hello, I've built a project with SocketIO in unreal v4.21.2. I used the version of SocketIO for v4.21 and v4.22. Everything works fine when I run from the editor, but trying to package the project fails with "unknown build error".

    I've attached the output log from Unreal, and the log file from appdata - can you tell me what is going wrong?

    I'm not very used to packaging projects with plugins, so perhaps I've not set things up correctly.

    This is a fairly urgent question for my project, as it has to go live in a couple of days, so thanks in advance for any response.

    Edit:
    - I've made sure my project is a Blueprints and C++ project, https://allarsblog.com/2015/11/05/co...roject-to-cpp/
    - I've also added "SocketIOClient" to ProjectBuild.cs under PublicDependencyModuleNames

    - I installed this plugin by downloading from github, but I also notice there is this: https://launcher-website-prod07.ol.e...cket-io-client
    is that something I need to package this?

    Edit 2: I think I've answered my own question, it seems like I was using SocketIO for Unreal 4.22 instead of the version for Unreal 4.21!
    Attached Files
    Last edited by samuelthomson; 09-13-2019, 07:34 AM.

    Leave a comment:


  • replied
    Plugin updated to v1.1.0
    There were a lot of changes for this release

    Some key features:

    Emit with Graph callback. Now you can 'get' information from the server without breaking your graph flow



    Static Component Construction. Want to add socket.io connections to your game instances or game modes without using C++? This is now supported with same API you're used to





    Convert wav and opus bytes to Soundwaves so you can play them. Should make it easier to test VOIP systems based on socket.io. You can also now issue event callbacks to arrive on your network thread if latency is a high priority (keep in mind that you'll need only do threadsafe actions on background threads i.e. no UObject allocation).



    There are also utility bps that allow you to do basic multi-threading in blueprint. e.g. enter a background thread, do some heavy computation task and callback on game thread with result.




    In SIOJson, you can now interweave Enum types in structs and they will be correctly translated into their string equivalent.

    (see https://github.com/getnamo/socketio-...ases/tag/1.1.0 for full details).

    Marketplace update has been submitted and pending.

    If you've been having disconnection problems, try out the new release and let me know if any new issues crop up!

    Leave a comment:


  • replied
    Originally posted by DonFrag View Post

    I think i didi it
    Almost . You opened a pull request alright, but that's just to merge my issue-150 branch into master. What you need to do is to fork master, edit the change and open a pull request to merge your edited fork into e.g. master

    Click image for larger version

Name:	fork-repo.PNG
Views:	1
Size:	21.1 KB
ID:	1659948

    Leave a comment:


  • replied
    Originally posted by getnamo View Post

    If you're willing to try something new, check out https://help.github.com/en/articles/...a-pull-request to learn how to make a pull request.

    The basics:
    - Fork the repository so you get a local copy.
    - Make the code change and commit to your local fork
    - Open a pull request with the change to the main repository and I'll merge it in
    I think i didi it

    Leave a comment:


  • replied
    Originally posted by Tiirazom View Post
    Hello!

    I can't connect to server. Event ConnectionProblem is happened, but event Connect (or Disconnect) isn't. Actor with SocketIOClient Component place at level, server is ok too, I suppose. How can I to find out reason of this problem? What can I do?
    http://prntscr.com/ow3b5j

    Thanks for help.
    Open an issue on https://github.com/getnamo/socketio-client-ue4/issues with detailed description on how to reproduce your bug and I'll take a look

    Leave a comment:


  • replied
    Originally posted by DonFrag View Post

    Uhm i don't know how to do that :/
    If you're willing to try something new, check out https://help.github.com/en/articles/...a-pull-request to learn how to make a pull request.

    The basics:
    - Fork the repository so you get a local copy.
    - Make the code change and commit to your local fork
    - Open a pull request with the change to the main repository and I'll merge it in

    Leave a comment:


  • replied
    Originally posted by getnamo View Post

    Nice! Likely only possible with statically allocated components, but this is a good catch. Open a pull request on https://github.com/getnamo/socketio-client-ue4 with the change and I'll merge it in
    Uhm i don't know how to do that :/

    Leave a comment:


  • replied
    Originally posted by DonFrag View Post
    I made a change. When i stop the PIE while is emiting on update the editor crashes

    added this line
    if (!NativeClient.IsValid())return;

    Nice! Likely only possible with statically allocated components, but this is a good catch. Open a pull request on https://github.com/getnamo/socketio-client-ue4 with the change and I'll merge it in

    Leave a comment:


  • replied
    Hello!

    I can't connect to server. Event ConnectionProblem is happened, but event Connect (or Disconnect) isn't. Actor with SocketIOClient Component place at level, server is ok too, I suppose. How can I to find out reason of this problem? What can I do?
    http://prntscr.com/ow3b5j

    Thanks for help.

    Leave a comment:


  • replied
    I made a change. When i stop the PIE while is emiting on update the editor crashes

    added this line
    if (!NativeClient.IsValid())return;

    Leave a comment:


  • replied
    Originally posted by Lolukok View Post
    Dear Folks,
    unknowing if there is any information about it already (I found none), I post here in desperation for help

    Right now I have a setup working with the plugin between two unreal projects to transmit data (pictures as binary, text and number information as json...). But it wont emit data that seems bigger than only a bit of text. And also it does not work if I repeatedly emit smaller things.
    Click image for larger version

Name:	foreachdelay.JPG
Views:	1
Size:	358.5 KB
ID:	1653403
    This is my setup to transmit images I collect. The image itself works great with the same setup without a loop.
    But when I try this, I can see in the server console that it sends 2 or 3 times and then disconnects the client.

    After that I have a ghost client that connects and disconnects. With other data I had the problem, that the ghost client kept reconnecting, even if I closed Unreal (it somehow kept a process running in the background with 20% CPU usage, and multiplied itself..)

    At this Point I just have no idea where to start since I have no Idea what and where the Error comes from. Do I need to make another setting in the plugin? I use the node server that came with the chat server example, is that wrong?

    I really appreciate any help or wink in the right direction!!

    best
    Luk
    I suspect it has to do with the standalone asio having some bug in the earlier v1.11 that is used in plugin v1.0. An early test inside https://github.com/getnamo/socketio-...tree/issue-126 which upgraded asio (to v1.13) seems to work with large data again (I've been testing it with raw audio binaries interwoven). If you want to try the unstable build, pull from issue-126 branch and compile. I'll be merging the potential fix into a stable build when I finally address issue-126 (reconnection cycle problem).

    Leave a comment:

Working...
X