Facility Control

 View Only
  • 1.  Keep HTTP Connection Open

    Posted 10-10-2018 03:01

    Hey there,

    This is a bit of a proactive question, as I have only experimented a little while I'm waiting on the correct API keys to use this.

    So, I am working on a Dashboard Panel that will grab Facebook Live comments associated with a live video id. They are available in JSON, that part is straight forward. However, they send them in an open stream that I would need to continually process, kind of like how a listener works.

    So Facebook provides two suggestions in their Graph API for live comments:

    var source = new EventSource("https://streaming-graph.facebook.com/[live-video-id]/live_comments?access_token=[user-access-token]&comment_rate=ten_per_second&fields=from{name,id},message");
    source.onmessage = function(event) {
      // Do something with event.message for example
    };

    or just a simple GET

    GET https://streaming-graph.facebook.com/[live-video-id]/live_comments?
      access_token=[user-access-token]&
      comment_rate=ten_per_second&
      fields=from{name,id},message

    So Dashboard's javascript engine does not seem to recognize EventSource. this would be my preferred way to access this, and would be very similar to a listener on a TCP/UDP port.

    Option 2 would potentially work, but the way facebook sends the posts is in a continuous stream, so I would not refresh again, I would need to keep it open and process new entries as they come. So, if I use asyncPost its probably going to write the data back but I feel like it will never finish and save as facebook will keep sending content. If there are no new posts it sends back a keep alive ping. The posts would probably make it in after the show is over and FB closes the connection.

    Any good ideas on how to work with this? Is there another command similar to EventSource that I could use to open that HTTPS connection?

    Also for reference, Facebook's Graph API info https://developers.facebook.com/docs/graph-api/server-sent-events/endpoints/live-comments/

    Thanks!



  • 2.  RE: Keep HTTP Connection Open

    Posted 10-10-2018 04:34
    I've been writing a lot of "helper apps" outside of Dashboard to meet my needs lately, so because that's my current mindset I thought I would toss this idea out:

    Since you're familiar with JavaScript, maybe you could create something in Node.js that gets the JSON data from Facebook and continuously saves it to a local file, and then have Dashboard open and parse that local file on a timer. Or, instead of writing to a file, in Node you could trigger a GPI in Dashboard to poll your Node server for new data and add it to a local array.

    Might be overkill, but just something that came to mind. Good luck!
    #DashBoard


  • 3.  RE: Keep HTTP Connection Open

    Posted 10-10-2018 15:01
    You are correct about the DashBoard asyncPost not completing if there is a continuous stream of data. It is designed to fetch content (or execute a restful call) and return when done.

    If the URL were HTTP instead of HTTPS, you would be able to implement this via a listener and process the content as it comes in. Because it is HTTPS, you won't be able to write directly to the TCP socket as it is an encrypted connection.

    Having a listener capable of connecting to a websocket or other HTTP stream has been added to our feature request database but, for now, an approach like the one suggested by @josephadams is going to yield better results. Our Inception Social product or directly-using DataLinq's data parsing capabilities outside of DashBoard may also be viable options depending on what exactly you're trying to do.

    James


    #DashBoard


  • 4.  RE: Keep HTTP Connection Open

    Posted 10-10-2018 17:16
    Thanks for the info! I figured a helper app might be required to do this. I'm probably going to run something on a web server that interprets the data and spits it out in a method that Dashboard can check on a regular interval.

    We have inception as well, and are using that for static posts (insta and facebook), but it doesn't really handle the live comments in way that is helpful for this application. We want to be able to have them essentially scroll, so the Social Media Producer can grab one and push it to air in seconds.
    #DashBoard