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!
Download
https://img.shields.io/github/release//socketio-client-ue4.svg
Available at:
https://github.com//socketio-client-ue4/releases
or
https://www.unrealengine.com/marketp…cket-io-client
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
Contribute
Still missing SSL via openssl https://github.com//socketio-client-ue4/issues
Quick Install & Setup
- Download Latest Release
- Create new or choose project.
- Browse to your project folder (typically found at Documents/Unreal Project/{Your Project Root})
- Copy Plugins folder into your Project root.
- 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
http://i.imgur.com/lSkfHQ2.png
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.
https://camo.githubusercontent.com/eab6a40ab7c42e3f788ba45b36d879856ebf68b9/687474703a2f2f692e696d6775722e636f6d2f645778436d76512e706e67
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.
https://camo.githubusercontent.com/07876d1bdcd2e43fdace023f4d7e16336bde1788/687474703a2f2f692e696d6775722e636f6d2f76566c4e426c782e706e67
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
https://camo.githubusercontent.com/8a717ed3d46ba6b51912051c73ed42c68b18ff0a/687474703a2f2f692e696d6775722e636f6d2f6e69684d53507a2e706e67
Changelist
See latest changes at https://github.com//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](https://github.com//socketio-client-ue4/issues/44), #45](https://github.com//socketio-client-ue4/issues/45), #55](https://github.com//socketio-client-ue4/issues/55), #56](https://github.com//socketio-client-ue4/issues/56), #57](https://github.com//socketio-client-ue4/issues/57), #60](https://github.com//socketio-client-ue4/issues/60), and #63](https://github.com//socketio-client-ue4/issues/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](https://github.com//socketio-client-ue4/issues/59) fix merged in f640f63
-Auto-conversion for As String if string type not supplied. Issue #64](https://github.com//socketio-client-ue4/issues/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](https://github.com//socketio-client-ue4/issues/65) fix merged in 591c150
-FSocketIONative now exposed as API. Issue #66](https://github.com//socketio-client-ue4/issues/66) merged in 7e32f70 spotted by GeneralD
0.6.0
-Rebased to accomodate #43](https://github.com//socketio-client-ue4/issues/43). You can now put FSocketIONative anywhere with your own allocation structure.
-‘On’ event dispatch changed to ‘OnEvent’.
-Candidate fixes for #41](https://github.com//socketio-client-ue4/issues/41), #32](https://github.com//socketio-client-ue4/issues/32), and #38](https://github.com//socketio-client-ue4/issues/38)
-Fixes to underlying library stopping re connection attempts when you close a connection: /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