1 | from abc import abstractmethod
|
---|
2 | from typing import List, Optional
|
---|
3 |
|
---|
4 | from geniusweb.actions.Action import Action
|
---|
5 | from geniusweb.inform.Agreements import Agreements
|
---|
6 | from geniusweb.progress.Progress import Progress
|
---|
7 | from geniusweb.protocol.NegoState import NegoState
|
---|
8 | from geniusweb.protocol.session.SessionResult import SessionResult
|
---|
9 | from geniusweb.protocol.session.SessionSettings import SessionSettings
|
---|
10 |
|
---|
11 |
|
---|
12 | class SessionState(NegoState):
|
---|
13 | '''
|
---|
14 | The current state of the session. E.g. typically contains the actions so far
|
---|
15 | and the parties currently connected. <br>
|
---|
16 | The state checks if transitions (Actions from the party) are following the
|
---|
17 | protocol, and thus implement most of the protocol . <br>
|
---|
18 |
|
---|
19 | If protocol errors occur, these should be stored in the state and the state
|
---|
20 | should become {@link #isFinal(long)}. Throwing should happen only in case of
|
---|
21 | a bug.<br>
|
---|
22 |
|
---|
23 | Implementations should be immutable (to ensure thread safety, testability
|
---|
24 | etc).
|
---|
25 |
|
---|
26 | States must be serializable so that listeners can follow what is going on in
|
---|
27 | the protocol. As uaual, mark non-serializable fields as transient.
|
---|
28 | '''
|
---|
29 |
|
---|
30 | @abstractmethod
|
---|
31 | def getSettings(self) -> SessionSettings:
|
---|
32 | '''
|
---|
33 | @return the SessionSettings
|
---|
34 | '''
|
---|
35 |
|
---|
36 | @abstractmethod
|
---|
37 | def getActions(self) -> List[Action]:
|
---|
38 | '''
|
---|
39 | @return unmodifyable list of actions done so far, in the order in which
|
---|
40 | they arrived. List of list allows implementations to add some
|
---|
41 | extra structure to the actions, eg one list per phase
|
---|
42 | '''
|
---|
43 |
|
---|
44 | @abstractmethod
|
---|
45 | def getProgress(self) -> Optional[Progress]:
|
---|
46 | '''
|
---|
47 | @return the progress of the session. Can return null if the session did
|
---|
48 | not even start yet. Notice that the protocol determines when a
|
---|
49 | session officially starts (eg, in SAOP it starts after all
|
---|
50 | parties were connected succesfully).
|
---|
51 | '''
|
---|
52 |
|
---|
53 | @abstractmethod
|
---|
54 | def getAgreements(self) -> Agreements:
|
---|
55 | '''
|
---|
56 | @return the current standing agreements
|
---|
57 | An agreement does not necessarily mean {@link #isFinal(long)}.
|
---|
58 | '''
|
---|
59 |
|
---|