Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I've a hard time getting started with libwebsockets #3206

Open
ju-emb opened this issue Aug 18, 2024 · 2 comments
Open

I've a hard time getting started with libwebsockets #3206

ju-emb opened this issue Aug 18, 2024 · 2 comments

Comments

@ju-emb
Copy link

ju-emb commented Aug 18, 2024

Sorry, that's not an issue to libwebsockets, but to me.

libwebsockets is very well thought and made. Congrats and thanks for that.

3 days I'm browsing examples, compile run and try them ...
Since I'm new to websockets I got a far understanding of it.

The issue I have is, get started writing a server that responds to an existing client.
The client app is artisan-scope sending some JSON requests and expecting an answer.

I tried to use the echo server example to get connected to the client and hoped I can see what the client is sending.
I got connected, but I'm to stupid to filter out the data coming from the client.

any hint's how I can do that.

Since libwebsockets does a lot in the background and uses mostly it's own types for variables and functions, I've no clue how to get to see what I want to see.

My understanding so far is, I have to implement the protocol the client comes with.
I have to get the data he send, and I have to respond the requests.

Now I need to see:
What protocol the client comes with. So I can implement that protocol
Need to extract the JSON data he send in order to respond to them.

Now my question
What's the "libwebsocket-way" to do that

thanks for your patience
Ju

@lws-team
Copy link
Member

This is doing things in http or ws? I presume it is ws but you don't actually say.

It sounds like you just want to look at https://github.com/warmcat/libwebsockets/tree/main/minimal-examples-lowlevel/ws-server/minimal-ws-server

Modify https://github.com/warmcat/libwebsockets/blob/main/minimal-examples-lowlevel/ws-server/minimal-ws-server/protocol_lws_minimal.c to match what your existing client will connect to including the ws protocol name.

Modify LWS_CALLBACK_RECEIVE in the protocol to dump what it is sending, what to do about the protocol sending depends on the required rules for the protocol of when to send stuff.

@ju-emb
Copy link
Author

ju-emb commented Aug 23, 2024

Hi Andy,

sorry for late answering, and thanks for the pointer.
I had to ventilate my brain a bit after digging through all that code.
I'll have a look at that examples and follow your suggestion.

again thanks and keep up with the great work

ju

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants