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.
17 method::functionSelector
18 Subclasses return specific function selectors for objects that implement this as interface.
21 ## doOnServerBoot - link::Classes/ServerBoot::
22 ## doOnServerQuit - link::Classes/ServerQuit::
23 ## doOnServerTree - link::Classes/ServerTree::
26 not for registry with a server, but analogous are:
28 ## doOnCmdPeriod - link::Classes/CmdPeriod::
29 ## doOnStartUp - link::Classes/StartUp::
30 ## doOnShutDown - link::Classes/ShutDown::
34 Add an action or object for registry.
37 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.
40 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.
43 Remove an item or object from registry. If server is nil, remove from strong::default:: key.
46 Remove all items that are registered for a given server.
53 f = { |server| "------------The server '%' has booted.------------\n".postf(server) };
54 ServerBoot.add(f, \default);
55 s.quit; // quit the server and observe the post
57 ServerBoot.remove(f, \default); // remove it again
60 ServerBoot.add(f, Server.internal);
63 ServerBoot.removeAll; // clear all
69 f = { |server| "------------The server '%' has quit.------------\n".postf(server) };
70 ServerQuit.add(f, \default);
71 s.quit; // quit the server and observe the post
73 ServerQuit.remove(f, \default); // remove it again
75 ServerQuit.add(f, Server.internal);
78 ServerQuit.removeAll; // clear all
84 f = { |server| "-------The server '%' has initialised tree.-------\n".postf(server) };
85 g = { |server| 10.do { Group(server).postln } };
86 ServerBoot.add(f, \default);
87 ServerTree.add(g, \default);
88 s.boot; // boot and see how the actions are evaluated in order
89 // "cmd-period" (or equivalent) resends the groups.
91 ServerBoot.removeAll; // clear all
92 ServerTree.removeAll; // clear all