From: Steffen S. <ste...@gm...> - 2018-05-04 17:18:46
|
hello there, i have an "output.harbor" with "on_connect" and "on_disconnect" functions. these functions should add/remove the clients that connect/disconnect to a list. all clients should be output later in an api as json code ------------------------ clientlist = ref [] def on_client_connect(~headers, ~uri, ~protocol, client) = clientlist := list.add(client, !clientlist) end def on_client_disconnect(client) = clientlist := list.remove(client, !clientlist) end http_api = json_of(!clientlist) ------------------------ that works. but if i want the headers in this list too, i have the problem that the "list.remove_assoc" function can't handle sublist. (client,[headers]). like this: ------------------------ clientlist = ref [] def on_client_connect(~headers, ~uri, ~protocol, client) = clientlist := list.add((client, headers), !clientlist) end def on_client_disconnect(client) = clientlist := list.remove_assoc(client, !clientlist) end http_api = json_of(!clientlist) ------------------------ after days of searching for a solution I have now given up finding a solution myself. the concrete problem is that "list[key]" causes an error when "key" itself is a list. is there a way to deal with this? with friendly greetings, Steffen \ Prism-J Translated with www.DeepL.com/Translator from german |