HandyCache форум

Главная категория => English forum => Тема начата: reges007 от 11 января 2015, 07:57:10



Название: request function connections number
Отправлено: reges007 от 11 января 2015, 07:57:10
by default handycache function connections number only work with get_users_stat
is it possible to add new function connections number for hc.url ?

thank's


Название: Re: request function connections number
Отправлено: mai62 от 11 января 2015, 17:39:17
Usually for loading of URL used one connection. Or I didn't understand something?


Название: Re: request function connections number
Отправлено: reges007 от 11 января 2015, 20:23:46
you are right, but what I mean is
if the same url and load queue as use download manager
I want to limit the number of active connections to receive specific url, not the total active connection by user


other samples
I want to restrict a user open two tabs open youtube page
if one tab has to load the video and the other tabs video url will disconnect/refuse

my extension
Код:
--[[ <HCExtension>
@name          limit
@author        reges007
@version       1
@description   only one accept url at the same time
@rule          googlevideo.com/videoplayback
@event         BeforeRequestHeaderSend/Request

</HCExtension> ]]

function Request()
        local l = hc.get_users_stat('local')
        local lnk = re.find(hc.url, [[googlevideo.com/videoplayback]])
        if hc.method == 'GET' and lnk and l and l['local'].connections_number > 1 then
        hc.monitor_string = 'disconnect'
        hc.client_disconnect()
    end
end



this will immediately disconnect because user local is already/still active connection one or more

for it I asked is it possible function .connection_number for the url connection active?