litesoft
Diff Revisions
49
vs
858
for /trunk/Java/GWT/OldServer/src/org/litesoft/GWT/eventbus/server/nonpublic/ServerSideRemotePeerService.java
|
@@ -5,38 +5,47 @@ |
5 |
5 |
|
|
6 |
6 |
|
import org.litesoft.GWT.eventbus.client.nonpublic.*; |
7 |
7 |
|
import org.litesoft.GWT.eventbus.client.rpc.*; |
|
8 |
+ |
import org.litesoft.core.simpletypes.temporal.*; |
8 |
9 |
|
import org.litesoft.logger.*; |
9 |
10 |
|
|
10 |
11 |
|
public class ServerSideRemotePeerService implements RemotePeerService |
11 |
12 |
|
{ |
12 |
|
- |
private Set<String> mAddPeerInterestsForClient = new HashSet<String>(); |
13 |
|
- |
private Set<String> mRemovePeerInterestsForClient = new HashSet<String>(); |
14 |
|
- |
private List<ChannelEventPackage> mChannelEventsForClient = new ArrayList<ChannelEventPackage>(); |
15 |
|
- |
private Set<String> mAckPeerInterestsForClient = new HashSet<String>(); |
|
13 |
+ |
private final MillisecTimeSource mMillisecTimeSource; |
|
14 |
+ |
private final Set<String> mAddPeerInterestsForClient = new HashSet<String>(); |
|
15 |
+ |
private final Set<String> mRemovePeerInterestsForClient = new HashSet<String>(); |
|
16 |
+ |
private final List<ChannelEventPackage> mChannelEventsForClient = new ArrayList<ChannelEventPackage>(); |
|
17 |
+ |
private final Set<String> mAckPeerInterestsForClient = new HashSet<String>(); |
|
18 |
+ |
|
|
19 |
+ |
private final Logger mLogger; |
16 |
20 |
|
|
17 |
21 |
|
private Long mGiveUpAfter = null; |
18 |
|
- |
private Logger mLogger; |
19 |
22 |
|
private PeerSupportingEventBus mServerEventBus; |
20 |
23 |
|
|
21 |
|
- |
public ServerSideRemotePeerService( Logger pLogger, PeerSupportingEventBus pServerEventBus ) |
|
24 |
+ |
public ServerSideRemotePeerService( MillisecTimeSource pMillisecTimeSource, Logger pLogger, PeerSupportingEventBus pServerEventBus ) |
22 |
25 |
|
{ |
|
26 |
+ |
mMillisecTimeSource = MillisecTimeSource.deNull( pMillisecTimeSource ); |
23 |
27 |
|
mLogger = pLogger; |
24 |
28 |
|
mServerEventBus = (pServerEventBus != null) ? // |
25 |
29 |
|
pServerEventBus : // |
26 |
30 |
|
PeerSupportingEventBus.Null.INSTANCE; |
27 |
31 |
|
} |
28 |
32 |
|
|
|
33 |
+ |
public ServerSideRemotePeerService( Logger pLogger, PeerSupportingEventBus pServerEventBus ) |
|
34 |
+ |
{ |
|
35 |
+ |
this( null, pLogger, pServerEventBus ); |
|
36 |
+ |
} |
|
37 |
+ |
|
29 |
38 |
|
private synchronized void setGiveUpAfter( int pPollMillisecs ) |
30 |
39 |
|
{ |
31 |
40 |
|
if ( pPollMillisecs > 0 ) |
32 |
41 |
|
{ |
33 |
|
- |
mGiveUpAfter = new Date().getTime() + pPollMillisecs + 60000L * 5; // 5 minutes |
|
42 |
+ |
mGiveUpAfter = mMillisecTimeSource.now() + pPollMillisecs + 60000L * 5; // 5 minutes |
34 |
43 |
|
} |
35 |
44 |
|
} |
36 |
45 |
|
|
37 |
46 |
|
private boolean okToCollect() // synchronized by forwardTo() |
38 |
47 |
|
{ |
39 |
|
- |
return (mGiveUpAfter == null) || (new Date().getTime() < mGiveUpAfter); |
|
48 |
+ |
return (mGiveUpAfter == null) || (mMillisecTimeSource.now() < mGiveUpAfter); |
40 |
49 |
|
} |
41 |
50 |
|
|
42 |
51 |
|
private synchronized PeerSupportingEventBus getServerEventBus() |