source: geniuswebcore/geniusweb/events/AbstractEvent.py@ 92

Last change on this file since 92 was 90, checked in by Bart Vastenhouw, 3 years ago

Refactor to help reusing partiesserver.

File size: 724 bytes
Line 
1from abc import ABC
2import time
3from geniusweb.events.NegotiationEvent import NegotiationEvent
4
5
6
7class AbstractEvent (NegotiationEvent, ABC):
8
9 def __init__(self, now:int=round(1000*time.time())):
10 '''
11 @param now the current time to use. see {@link System#currentTimeMillis()}.
12 Defaults to current time.
13 '''
14 if now == None or now < 0:
15 raise ValueError("time must be non-null and positive")
16
17 self._time = now;
18
19
20 def getTime(self) ->int:
21 return self._time
22
23
24 def __repr__(self) ->str:
25 return str(self.__class__.__name__) + "[" + str(self._time) + "]";
26
27 def __hash__(self):
28 return hash(self._time)
29
30
31 def __eq__(self, other):
32 return isinstance(other, self.__class__) and \
33 self._time==other._time
34
35
Note: See TracBrowser for help on using the repository browser.