AIRServer 0.5 – socket byte concatenation

I’ve just finished work on a little update of my AIRServer library (version 0.5, hooray!). Apparently, when you send large chunks of data over the socket (like sending an image to the server, over the socket), it could happen the data is split over multiple packages. This caused errors on the server side.

I’ve fixed that issue, and uploaded an updated version, together with an image-sending-demo. You can find the latest version on github. Enjoy!

4 Responses to “AIRServer 0.5 – socket byte concatenation”


  • Hey!! Congrats on this great Server!
    I’ve been using it for a project of mine, but I’m having some trouble sending messages to clients… They don’t seem to be working… I’m trying to send the message like this:

    var message= new Message();
    message.data = “SERVER_FULL”; airServer.getClientById(event.client.id).sendMessage(message);

    and then receive it with this in javascript:
    if(decoded.data == “SERVER_FULL”){
    alert(“SERVER_FULL”);
    }

    But it’s not working! :( Any ideas??
    Thanks!!

  • @jan make sure you replace unwanted characters before you JSON decode:

    function socketMessageHandler(msg)
    {
    var decoded = JSON.parse(msg.data.replace(/[\u0000\u00ff]/g, ”));
    alert(decoded.command + “: ” + decoded.data);
    }

  • Great job on the Air Server. One thing i don’t understand.. Is there a time out ? It seems like clients get removed after a few minutes.. Any idea why ?

    Thanks

  • will this work on mobile devices, to allow you to setup a server socket? I ask because Adobe’s ServerSocket class is not available on air mobile devices.

Leave a Reply