Skip to main content
richard_anacion
Participant
March 6, 2015
Question

how to improve this code

  • March 6, 2015
  • 1 reply
  • 328 views

i have a code which only allowed ip list below in adobe media server main.asc.

any other code? i want 10 ip's allowed to be publish.

thanks,

application.onPublish = function(p_client, streamname){

    if (p_client.ip != "123.123.123.123" && p_client.ip != "123.123.123.129" && p_client.ip != "222.222.222.222"){

        application.disconnect(p_client);

    }

}

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    March 6, 2015

    In other languages I usually done such checks by using arrays:

    if ([1, 2, 3].indexOf(value) < 0) {

      // an action

    }


    But with for FMS I had to add indexOf method which is absent in as1

    Core JavaScript Reference 1.5: Core JavaScript Reference | WebReference

    // indexOf helper

        ArrayIndexOf = function(array, elt) {

       var len = array.length >>> 0;
       var from = Number(arguments[2]) || 0;
       from = (from < 0) ? Math.ceil(from) : Math.floor(from);
       if (from < 0) from += len;
       for (; from < len; from++) {
            if (from in array && array[from] === elt) return from;
       }
       return -1;

        }