source: party/src/main/java/geniusweb/party/Party.java@ 52

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 2.6 KB
Line 
1package geniusweb.party;
2
3import geniusweb.actions.Action;
4import geniusweb.connection.Connectable;
5import geniusweb.connection.ConnectionEnd;
6import geniusweb.inform.Inform;
7
8/**
9 * This is a interface definition for java-based party implementations that are
10 * to be run on the PartiesServer.
11 *
12 * To implement a party to run on the PartiesServer, you must implement this and
13 * also have a 0-arg constructor. Also we strongly recommend not to use any
14 * static code blocks or do anything serious in the constructor. Instances of
15 * your class may also be created only to call the getCapabilities function.
16 *
17 * <h2>Short outline</h2> After the party is created (empty constructor) it is
18 * first connected through a call to connect (from the {@link Connectable}
19 * interface). The party can subscribe to receive {@link Inform} objects using
20 * {@link ConnectionEnd#addListener(tudelft.utilities.listener.Listener)}. The
21 * party can also send its actions using {@link ConnectionEnd#send(Object)}.
22 *
23 * The {@link ConnectionEnd} allows the party to receive Inform objects and send
24 * action objects.
25 *
26 * Incoming Inform objects (eg "Settings" containing the profile, and
27 * "yourturn") are notified to the party throught he notifyChange() call to the
28 * party.
29 * <p>
30 * Outgoing Action objects (eg "Offer") are sent using the send() command.
31 *
32 * Most parties extend {@link DefaultParty} to handle these connection details.
33 * <p>
34 * Technical details: normally a Party will be spawned inside a PartiesFactory,
35 * and incoming/outgoing calls are routed through a websocket there. But in
36 * testing the Connectable is often mocked.
37 *
38 */
39public interface Party extends Connectable<Inform, Action> {
40
41 /**
42 * @return the capabilities of this party.
43 */
44 Capabilities getCapabilities();
45
46 /**
47 *
48 * @return some useful short description, eg "tit-for-tat with bayesian
49 * opponent modeling".
50 */
51 String getDescription();
52
53 /**
54 * When this is called, the party must free up all its claimed resources
55 * (memory, CPU, files, etc) immediately. This call can come in at any time
56 * (when a negotiation is aborted early), even while your party is still
57 * working on something else. Other parties for the next session may be
58 * started within a few seconds after this request to your party. The exact
59 * time is decided by the partyserver you use but typically 2 seconds. Not
60 * respecting this call and continue using the system resources will
61 * deteriorate performance of other parties running on the same machine,
62 * which may be against the assignment/competition rules.
63 */
64 void terminate();
65}
Note: See TracBrowser for help on using the repository browser.