1 class:: AbstractServerAction
2 summary:: register actions to be taken for a server
3 related:: Classes/Server, Classes/ServerBoot, Classes/ServerTree, Classes/ServerQuit
8 This is an strong::abstract superclass:: for singletons like link::Classes/ServerQuit::, which provides a place for registering functions and objects for events that should happen when something happens in the server.
9 No direct call to AbstractServerAction is required.
11 note:: not fully working on linux and windows.
12 Setting the computer to sleep on these systems causes the actions to be called.
13 As to date in linux, JACK does not survive a sleep, it nevertheless behaves correctly for the time being.
18 method::functionSelector
19 Subclasses return specific function selectors for objects that implement this as interface.
22 ## doOnServerBoot - link::Classes/ServerBoot::
23 ## doOnServerQuit - link::Classes/ServerQuit::
24 ## doOnServerTree - link::Classes/ServerTree::
27 not for registry with a server, but analogous are:
29 ## doOnCmdPeriod - link::Classes/CmdPeriod::
30 ## doOnStartUp - link::Classes/StartUp::
31 ## doOnShutDown - link::Classes/ShutDown::
35 Add an action or object for registry.
38 Can either be a link::Classes/Function:: to be evaluated (as first arg the server is passed in), or an link::Classes/Object:: that implements the message returned by link::#-functionSelector::. strong::One object is only registered once::, so that multiple additions don't cause multiple calls.
41 Server for which to register. If the symbol strong::\default:: is passed in, the action is called for the current default server. If the symbol strong::\all:: is passed in, the action is called for all current servers. If server is nil, it is added to \default.
44 Remove an item or object from registry. If server is nil, remove from strong::default:: key.
47 Remove all items that are registered for a given server.
54 f = { |server| "------------The server '%' has booted.------------\n".postf(server) };
55 ServerBoot.add(f, \default);
56 s.quit; // quit the server and observe the post
58 ServerBoot.remove(f, \default); // remove it again
61 ServerBoot.add(f, Server.internal);
64 ServerBoot.removeAll; // clear all
70 f = { |server| "------------The server '%' has quit.------------\n".postf(server) };
71 ServerQuit.add(f, \default);
72 s.quit; // quit the server and observe the post
74 ServerQuit.remove(f, \default); // remove it again
76 ServerQuit.add(f, Server.internal);
79 ServerQuit.removeAll; // clear all
85 f = { |server| "-------The server '%' has initialised tree.-------\n".postf(server) };
86 g = { |server| 10.do { Group(server).postln } };
87 ServerBoot.add(f, \default);
88 ServerTree.add(g, \default);
89 s.boot; // boot and see how the actions are evaluated in order
90 // "cmd-period" (or equivalent) resends the groups.
92 ServerBoot.removeAll; // clear all
93 ServerTree.removeAll; // clear all