how to send() string or binary?

1,317 views
Skip to first unread message

jimbo...@gmail.com

unread,
Jul 8, 2013, 10:12:52 PM7/8/13
to webso...@googlegroups.com
This is probably really silly, and I've looked at the source, but how do I send strings and binaries?

Maybe my question should be: how do I form message_ptrs?

jimbo...@gmail.com

unread,
Jul 8, 2013, 10:20:29 PM7/8/13
to webso...@googlegroups.com
Sorry, for clarity's of my lack of skill sake: I'm doing (building on top of broadcast server)

send(*it,std::string)

and it won't compile.

Peter Thorson

unread,
Jul 8, 2013, 11:23:05 PM7/8/13
to jimbo...@gmail.com, webso...@googlegroups.com
The various send methods take an opcode as a parameter. websocketpp::frame::opcode::text will send the data as a UTF8 string message and websocketpp::frame::opcode::binary will send as raw binary. All other opcodes are reserved by RFC6455 for future use. There are overloads for both std::string, void *. You can send either as text or binary. These methods will create a message buffer / message_ptr and immediately add it to the outgoing message queue.

There is an experimental api for manually generating raw message buffers and sending them directly. It is not fully complete yet and isn't ready for production use.

On Jul 8, 2013, at 21:12 , jimbo...@gmail.com wrote:

This is probably really silly, and I've looked at the source, but how do I send strings and binaries?

Maybe my question should be: how do I form message_ptrs?

--
You received this message because you are subscribed to the Google Groups "WebSocket++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websocketpp...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

jimbo...@gmail.com

unread,
Jul 8, 2013, 11:50:14 PM7/8/13
to webso...@googlegroups.com, jimbo...@gmail.com
OK, I think I get it now.

Now that I know what to look for, I think I found an example in telemetry server.

Thank-you!

fry...@gmail.com

unread,
Oct 5, 2013, 3:32:05 AM10/5/13
to webso...@googlegroups.com
     char ch[10];
    for(int i=0;i<10;i++)
    ch[i]=65+i;
    ch[8]=0;
    //myMsg.set_opcode(websocketpp::frame::opcode::binary);//websocketpp::frame::opcode::TEXT
    int len=sizeof(ch);
    m_server.send(hdl,ch,len,websocketpp::frame::opcode::binary);

It tests okay.

I want to put message to queue and start a thread to send them to clients.  My problem is I don't know how to construct a message! What i know is to send a binary buffer directly, but i want to send them through message_ptr.
Reply all
Reply to author
Forward
0 new messages