sacOO7/socketcluster-client-C

struct socket in scclient.c rather than in scclient.h

Closed this issue · 12 comments

Any specific reason on why struct socket is defined in scclient.c rather than (ideally) in scclient.h?

Yes, able to connect and send/receive messages. Also, getting disconnect event after server stop.

./emitter
connecting...
[2018/02/15 10:19:03:8775] NOTICE: Initial logging level 7
[2018/02/15 10:19:03:8797] NOTICE: Libwebsockets version: 2.0.3 unknown-build-hash
[2018/02/15 10:19:03:8820] NOTICE: IPV6 not compiled in
[2018/02/15 10:19:03:8842] NOTICE: libev support compiled in but disabled
[2018/02/15 10:19:03:8863] NOTICE: libuv support compiled in but disabled
[2018/02/15 10:19:03:8896] NOTICE: Threads: 1 each 1024 fds
[2018/02/15 10:19:03:8898] NOTICE: mem: platform fd map: 4096 bytes
[2018/02/15 10:19:03:8900] NOTICE: Compiled with OpenSSL support
[2018/02/15 10:19:03:9232] NOTICE: Creating Vhost 'default' port -1, 1 protocols
[2018/02/15 10:19:03:9312] NOTICE: mem: per-conn: 600 bytes + protocol rx buf
[2018/02/15 10:19:03:9330] NOTICE: canonical_hostname = UNIT2
[Main] context created.
[Main] wsi create success.
[2018/02/15 10:19:03:9990] NOTICE: lws_protocol_init
[2018/02/15 10:19:12:8070] NOTICE: lws_context_destroy
successfully connected
Authentication is false
successfully dis-connected

Will do. But, i need to rearrange the code urgently. we need to use multiple socketcluster services but currently this is not possible because of global socket variable *s. Is there a way to pass a context containing socket to ws_service_callback?

We will be happy to change it. Then, you can review it. But for now we need to figure out how to pass the socket to ws_service_callback. That is the only function where socket is needed. Any ideas?

As good as this stuff is, unfortunately we will have to start from scratch using libwebsockets. We can not create a separate thread for every emit but will have to handle all the emits in one existing threads possibly by queuing messages.

Can you help us with issues that will arise specially with the initial handshake?

Yeah I surely can :)

Thanks @sacOO7 . For now, we ended up writing c++ client with Boost::Beast. It is extremely easy with inclusion of Beast in Boost starting 1.66.0. But, we would like to help you clean up c client as well when time permits. For now, I will close this one.

Thank you @cogmeta. I am really grateful 👍

Hi @cogmeta , if you feel to have any changes in library, Feel free to create a Pull Request. We are actively looking for potential contributors as good as you 👍. Thank you 👍