anyway, it's only useful if you wish to keep your connection numbers 
*per* port (and you do use multiple ports for one single hostname), if 
you don't care then you can throw away the map, completely. And it's 
much shorter to write then.
Otherwise make sure the map is located on top of your script, not 
included in the same function as the one that already includes your 
harbour call.

On 09/09/2011 17:35, Guillaume (Numerizik) wrote:
> Hello
>
> I have this message
>
> # At line 85, char 7:
>    this value has type
>      [(_*int)] (infered at line 81, char 31-48)
>    but it should be a subtype of
>      [(_*string)]
>
> Line 81 is
> ref_conn_limit_per_port = ref [("dummy_port",0)]
>
> Line 85 is
> def get_m(key) =
>      _m = !ref_conn_limit_per_port
> 85    _m[key]
> End
>
> thanks
> -----Message d'origine-----
> De : okay_awright [mailto:[email protected]]
> Envoyé : vendredi 9 septembre 2011 16:53
> À : Guillaume (Numerizik)
> Cc : [email protected]
> Objet : Re: [Savonet-users] output.harbor - on_connect
>
> Hi,
> and what about something simpler if you don't want to export those values
> outside liquidsoap, please note that it's been written on the fly and it's
> thus untested, but I hope you get the pitch (i.e. reference to a
> map/dictionary):
>
> ref_conn_limit_per_port = ref [("dummy_port",0)]
>
> def get_m(key) =
>      _m = !ref_conn_limit_per_port
>      _m[key]
> end
> def unset_m(key) =
>      ref_conn_limit_per_port := list.remove_assoc(key,
> !ref_conn_limit_per_port)
> end
> def set_m(key, value) =
>      unset_m(key)
>      ref_conn_limit_per_port := list.append( [(key, value)],
> !ref_conn_limit_per_port)
> end
>
> def on_connect(port) =
>      log("connect to stream...");
>      #counter++
>      new_limit = get_m(port)
>      new_limit = new_limit + 1
>      set_m(port, new_limit)
> end
> def on_disconnect(port) =
>      log("disconnect from stream...");
>      #counter--
>      new_limit = get_m(port)
>      new_limit = new_limit - 1
>      set_m(port, new_limit)
> end
>
> output.harbor(%mp3(bitrate=128),on_connect=on_connect,on_disconnect=on_disco
> nnect,port=1234,mount="listen",url="http://www.google.com",icy_metadata="tru
> e",protocol="icy",source)
>
> --
> best regards,
>
> okay_awright
> <okay_awright AT ddcr DOT biz>
> [PGP key on request]
>
> On 09/09/2011 16:26, Guillaume (Numerizik) wrote:
>> Hello
>>
>> I want to connect on one page to know how many connect i have to my
>> stream (with output.harbor)
>>
>> Here my script. Can you help me ?
>>
>> def on_connect(~port) =
>>     log("connect to stream...");
>>     http.get("http://localhost80/status.php?id=~port";);
>> end
>>
>> output.harbor(%mp3(bitrate=128),on_connect=on_connect,port=1234,mount=
>> "liste
>> n",url="http://www.google.com",icy_metadata="true",protocol="icy",sour
>> ce)
>>
>>
>> http://localhost80/status.php?id=~port record on one database and
>> increase value. I'll use on_disconnect to limit connection...
>>
>> what do you think?
>>
>> thanks
>>
>>
>> ----------------------------------------------------------------------
>> -------- Why Cloud-Based Security and Archiving Make Sense Osterman
>> Research conducted this study that outlines how and why cloud
>> computing security and archiving is rapidly being adopted across the
>> IT space for its ease of implementation, lower cost, and increased
>> reliability. Learn more.
>> http://www.accelacomm.com/jaw/sfnl/114/51425301/
>> _______________________________________________
>> Savonet-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/savonet-users
>
>
>

-- 
best regards,

okay_awright
<okay_awright AT ddcr DOT biz>
[PGP key on request]

------------------------------------------------------------------------------
Why Cloud-Based Security and Archiving Make Sense
Osterman Research conducted this study that outlines how and why cloud
computing security and archiving is rapidly being adopted across the IT 
space for its ease of implementation, lower cost, and increased 
reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to