websocket example with server initiated data

Skip to first unread message

harsh P

Feb 3, 2017, 7:57:28 PM2/3/17
to onion-dev
I am struggling with basic example to run webSocket with libonion. I am 2 days old with the web programming.  
My ultimate goal is to achieve the following 
  1. start a websocket server on C++
  2. Listen for messages from client
  3. Send response for messages based on some processing in my custom code.
  4. SEND SERVER INITIATED text message/string to client when something changes on my custom code.
    How do I achieve the above ? Any example code?

Below I am trying to provide more information by dummy test class below.
class test
void processDataFromClient(const string & data);//this needs to get filled by websocket read method? how?
void pushDataToClient(const string & data);

test::pushDataToClient(const string & data)
(socketId, text) // how do I call this from my test.cpp ?

test::void processDataFromClient(const string & data)
//do some computation based on the text received
//turn on the light
//once Light is on for a minute call
pushDataToClient( lighton) ;

//open a webSocket
//listen for messages from client i.e pass data received from onion_websocket_read to test class by calling processDataFromClient();
//send asynchronous messages to client received from test class. i.e. pushDataToClient should invoke onion_websocket_write //do we need a thread for this ? how to achieve this?


Reply all
Reply to author
0 new messages