Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Websocket feature  (Read 4615 times)

0 Members and 1 Guest are viewing this topic.

pinko64

  • Newbie
  • *
  • Posts: 12
    • View Profile
Websocket feature
« 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.




Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Websocket feature
« Reply #1 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).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
AW: Re: Websocket feature
« Reply #2 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...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Websocket feature
« Reply #3 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Websocket feature
« Reply #4 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

pinko64

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Websocket feature
« Reply #5 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.