On Wednesday, 28 January 2015 at 14:18:38 UTC, Trollgeir wrote:
I'm having some trouble trying to stream data to my plot.ly graph:
https://plot.ly/62/~Trollgeir/

The API:  https://plot.ly/streaming/

I am able to post messages that get recorded into the stream live, although right after curl uploads it, it just seems to wait for a response it's not getting, and eventually timeouts. Does anyone have any advice?

auto client = HTTP("stream.plot.ly");
client.addRequestHeader("plotly-streamtoken","e8bg6omat6");
client.verbose = true;

string msg = "{ \"x\": 500, \"y\": 500 } \n";
client.postData(msg);
client.perform; 

You have to define a handler for HTTP.onReceive before calling HTTP.perform. It will receive ubyte arrays for each packet that comes in. For most purposes, you just copy that onto the end of a string in an external scope. But if you're streaming content, you'll need to do something more fancy.

Reply via email to