Perhaps you could take a peek at the Emscripten web socket callback extensions, at https://github.com/kripken/emscripten/blob/master/system/include/emscripten/emscripten.h#L95, which get called also whenever a message occurs.
2016-09-27 13:24 GMT+03:00 Ciprian Tomoiaga <[email protected]>: > Hi all, > > I'm trying to figure out how I can use emscripten to get my project on the > web. Any pointers or ideas would be greatly appreciated! > I have a rendering application in C that uses: > > 1. OpenGL (with user buffers) and FreeGLUT > 2. sockets to dynamically get rendering data from a server > 3. threads (pThreads or OpenMP) to do point 2 asynchronously, without > blocking the rendering thread > > Basically, the background thread gets updated data from the server and > puts it in a global array. The main (rendering) thread just renders this > global array. > > > If I were to port it by hand, here's what I would do in JS (single > threaded): > > - I would detect the need to update and query the server via websocket > (and websockify proxy) > - in the "on_message" event, I would save the new data, passing it > from binary into doubles > - the server closes the connection after every query; therefore, in > the "on_close" event I would set a signal need_to_update = true; > - in the rendering function, if need_to_update I would update the > buffers with the previous data > > This is mono-threaded and most functions are quite small workers, I > believe. > > > It seems to be that the 2 approaches are highly incompatible, but I don't > want to port by hand all the data structure and rendering process. > > I was thinking of modifying the C code to resemble the JS structure > (removing the threads), but since C isn't event based, I'm not sure how to > proceed with the "on_message" part. > > > What solutions can I use ? Is there any example of any similar porting ? > > Many thanks for reading all this! :) Your experience will be greatly > appreciated. > > > Ciprian > > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
