WebSocket Client C++ HowTo

Hey,

i am trying to let my GameClient open a WebSocket Connection.
I found the libwebsockets package inside the Engine. But in the description of the Header file ther is written that its just a websocket server.

How else i can add websocket client functionality to my game ?

Greetings

Loki

Hi.

Unfortunatelly as far as I know the UE4 don’t have any good implementation for a websocket client.

I’ve written the new engine module that deal with it using the libwebsockets built from libwebsockets git.

The libwebsockets itself is quite low level stuff, but this file libwebsockets/test-client.c at master · davidgaleano/libwebsockets · GitHub can help You understand how to do it.

Unfortunatelly I can’t help more. NDA, this stuf… :frowning:

Whats about this ? Looks promising for me:

It looks ok for simple use. Just keep in mind there might be few issues:

  1. I can’t see any threading in this plugin.

  2. There is only binary sending, so when sending FStrings you have to perform a conversion.

  3. There is no support for self-signed certificates if You want to keep Your connection safe.

  4. There is no support for deflating packages, so make sure to keep Your packages small.

But I think it’s a good place to start, now I’m wondering why I didn’t find it at the first place :slight_smile:

Ok i am now using easywsclient. But i am looking for another solution.
This doesnt seems very stable (or more it lack features which i need)

Maybe i will try websocketpp

hello,
any update on websocketpp?
I use websocketpp Cinder block( GitHub - wieden-kennedy/Cinder-WebSocketPP: Cinder implementation of WebSocketPP ), I would like to have an Unreal websocket client…
thank you

You can find a Websocket implementation for the libwebsocket library located in Engine/Source/ThirdParty/WebSockets.

Part of the private classes of that library are an implementation of a WebSocket in C++. You can copy that class to your project, rename it and use the websocket connection. This will limit your project to Windows and maybe HTML5.

At least I did something similar half a year ago with Unreal 4.8, but my projects are now outside of my reach. I hope this helps. Good luck!

I write a websocket plugin for unreal engine 4,
you can use it with c++ or blueprint api.

https://github.com/feixuwu/UEWebsocket