SFML community forums

General => Feature requests => Topic started by: pinko64 on April 13, 2014, 02:59:03 pm

Title: Websocket feature
Post by: pinko64 on April 13, 2014, 02:59:03 pm
Websockets seems to be pretty cool way to add full-duplex network connection between an app and a web- browser.
It shouldn't be too hard to implement on using RFC 6455 specification.
sf::TcpSocket::Send and ..::Receive functions could take a sf::WebSocketPacket as an argument etc.

I think there are people that might find it useful.

As for now i'm writing my own implementation... which is a little bit dirty codewise so do not wanna share code.



Title: Re: Websocket feature
Post by: Ixrec on April 13, 2014, 04:49:34 pm
It is cool, but I don't see the use case outside of browsers.  SFML is not meant for implementing browsers (it has no HTML rendering or Javascript interpreters) or browser-based games (it has no HTML5/JS binding), and for regular C++ apps I'm pretty sure a TCP socket is already full-duplex.

If you actually need this for something, there are already a few C++ libraries like libwebsocket which can do this (though I don't know anything about them).
Title: AW: Re: Websocket feature
Post by: eXpl0it3r on April 14, 2014, 08:05:46 am
It is cool, but I don't see the use case outside of browsers.  SFML is not meant for implementing browsers (it has no HTML rendering or Javascript interpreters) or browser-based games (it has no HTML5/JS binding), and for regular C++ apps I'm pretty sure a TCP socket is already full-duplex.
Not sure if understood the concept here, ofc SFML wouldn't be used for rendering HTML, but it could be used as back-end/server. You can then make a two-way connection from your web browser.
I think it could be quite useful.

If you actually need this for something, there are already a few C++ libraries like libwebsocket which can do this (though I don't know anything about them).
I haven't found a nice library. libwebsocket is quite a mess...
Title: Re: Websocket feature
Post by: Ixrec on April 14, 2014, 08:08:58 am
Wouldn't you have to write a bunch of HTML and Javascript to make that work though?  Web browsers can't talk directly to server-side C++, can they?
Title: Re: Websocket feature
Post by: eXpl0it3r on April 14, 2014, 08:37:22 am
WebSockets are an HTML 5 feature, so yes for the client side (where the browser is) you write HTML and JavaScript and from that you can directly communicate with your sever (where the SFML network module would be used).
But SFML doesn't have to know anything about HTML to serve as back-end.
Title: Re: Websocket feature
Post by: pinko64 on April 14, 2014, 01:37:32 pm
Yes there are some libraries like libwebsocket( c ) and websocketpp( cpp ). But neither one is not nearly as easy to setup as sfml is. And their documentations is a pretty horrible to my taste.