-
Notifications
You must be signed in to change notification settings - Fork 129
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
on_msg_recv_callback #34
Comments
What error message did you get when you do this? |
Thank you very much for responding to my question. I like the simplicity of // for test purpose, send back a simple 5-byte text msg: ok:123
When I compile the modified code (using gcc), I got the following compiler myhost@UbuntuSRVS2S:~/ws-test/wslay-master/examples$ !gcc On Fri, Jul 15, 2016 at 10:40 PM, Tatsuhiro Tsujikawa <
|
arg->msg is const pointer to uint8_t, so you cannot modify the pointed region directly. arg is self const pointer. Instead, create your own buffer, and write your data into it, and use it as message, like so: const uint8_t buf[] = "hello";
struct wslay_event_msg msgarg = {arg->opcode, buf, sizeof(buf) - 1};
wslay_event_queue_msg(ctx, &msgarg); Although, manual does not say anything, but wslay_event_queue_msg makes a copy of msg of length msg_length. |
In my test case, the value returned to the peer in buf is dynamic. I only char reply_message[256]; < application code that would change the value of variable: reply_message> const uint8_t buf[] = reply_message On Sat, Jul 16, 2016 at 10:38 AM, Tatsuhiro Tsujikawa <
|
If you have message already in reply_message, you don't need to use const uint8_t buf[]. |
I did as you said by defining msgarg with my own data variables (see below): struct wslay_event_msg msgarg = {arg->opcode, replyMsg, replyMsg_length}; Then, it works! Thanks a lot. I have another question: how to tell the function (wslay_event_queue_msg) I really appreciate if you could point out a way to do this. The reason for On Tue, Jul 19, 2016 at 7:16 AM, Tatsuhiro Tsujikawa <
|
I use fork_echoserv.c as a base to write a simple application. Instead of echoing back a frame received, I use on_msg_recv_callback function to send back a different frame using wslay_event_queue_msg(ctx, &msgNew) where the last argument contains my own frame structure. But the function does not allow me to do so. What other functions can allow me to send back a different frame based on the content of the frame just received? Please provide some examples. Thank you very much.
harry
The text was updated successfully, but these errors were encountered: