|
@@ -1,45 +1,45 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.eventbus.client.nonpublic; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.*; |
5 |
|
- |
import org.litesoft.GWT.eventbus.client.*; |
6 |
|
- |
import org.litesoft.GWT.eventbus.client.rpc.*; |
7 |
|
- |
import org.litesoft.logger.*; |
8 |
|
- |
|
9 |
|
- |
import com.google.gwt.user.client.*; |
10 |
|
- |
|
11 |
|
- |
public class ClientEventBus extends AbstractPeerSupportingEventBus { |
12 |
|
- |
public ClientEventBus( int pClientIdNumber ) { |
13 |
|
- |
super( "Client", pClientIdNumber, TimedRunnableManager.INSTANCE, |
14 |
|
- |
AlertUnexpectedEventPackageHandler.INSTANCE ); |
15 |
|
- |
} |
16 |
|
- |
|
17 |
|
- |
public void initialize( ChannelServiceAsync pChannelServiceAsync, int pPollSecs, Logger pLogger ) { |
18 |
|
- |
if ( pLogger == null ) { |
19 |
|
- |
pLogger = createLogger(); |
20 |
|
- |
} |
21 |
|
- |
ClientSideRemotePeerService zPeerService = new ClientSideRemotePeerService( this, // |
22 |
|
- |
pChannelServiceAsync, // |
23 |
|
- |
pPollSecs ); |
24 |
|
- |
initialize( pLogger, new StatePeerSupportingEventBusSuspended( pLogger, this, zPeerService ) ); |
25 |
|
- |
} |
26 |
|
- |
|
27 |
|
- |
public void release() { |
28 |
|
- |
switchFromSuspendedToRegular().releaseCollected(); |
29 |
|
- |
} |
30 |
|
- |
|
31 |
|
- |
public void pollNow() { |
32 |
|
- |
/* |
33 |
|
- |
* Deferred execution. Works around a Safari bug where calling from a |
34 |
|
- |
* nested iframe somehow corrupts the RPC endpoint url. (It's not so |
35 |
|
- |
* much the delay as the context that this is called from). |
36 |
|
- |
*/ |
37 |
|
- |
DeferredCommand.addCommand( new Command() { |
38 |
|
- |
public void execute() { |
39 |
|
- |
publish( PingEventPackage.INSTANCE ); |
40 |
|
- |
} |
41 |
|
- |
} ); |
42 |
|
- |
} |
43 |
|
- |
|
44 |
|
- |
// todo: Client -> Server of Exception 'e': mEventBus.getTypeNameOf(e), + ":" + e.getMessage() |
45 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.eventbus.client.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.*; |
|
5 |
+ |
import org.litesoft.GWT.eventbus.client.*; |
|
6 |
+ |
import org.litesoft.GWT.eventbus.client.rpc.*; |
|
7 |
+ |
import org.litesoft.logger.*; |
|
8 |
+ |
|
|
9 |
+ |
import com.google.gwt.user.client.*; |
|
10 |
+ |
|
|
11 |
+ |
public class ClientEventBus extends AbstractPeerSupportingEventBus { |
|
12 |
+ |
public ClientEventBus( int pClientIdNumber ) { |
|
13 |
+ |
super( "Client", pClientIdNumber, TimedRunnableManager.INSTANCE, |
|
14 |
+ |
AlertUnexpectedEventPackageHandler.INSTANCE ); |
|
15 |
+ |
} |
|
16 |
+ |
|
|
17 |
+ |
public void initialize( ChannelServiceAsync pChannelServiceAsync, int pPollSecs, Logger pLogger ) { |
|
18 |
+ |
if ( pLogger == null ) { |
|
19 |
+ |
pLogger = createLogger(); |
|
20 |
+ |
} |
|
21 |
+ |
ClientSideRemotePeerService zPeerService = new ClientSideRemotePeerService( this, // |
|
22 |
+ |
pChannelServiceAsync, // |
|
23 |
+ |
pPollSecs ); |
|
24 |
+ |
initialize( pLogger, new StatePeerSupportingEventBusSuspended( pLogger, this, zPeerService ) ); |
|
25 |
+ |
} |
|
26 |
+ |
|
|
27 |
+ |
public void release() { |
|
28 |
+ |
switchFromSuspendedToRegular().releaseCollected(); |
|
29 |
+ |
} |
|
30 |
+ |
|
|
31 |
+ |
public void pollNow() { |
|
32 |
+ |
/* |
|
33 |
+ |
* Deferred execution. Works around a Safari bug where calling from a |
|
34 |
+ |
* nested iframe somehow corrupts the RPC endpoint url. (It's not so |
|
35 |
+ |
* much the delay as the context that this is called from). |
|
36 |
+ |
*/ |
|
37 |
+ |
DeferredCommand.addCommand( new Command() { |
|
38 |
+ |
public void execute() { |
|
39 |
+ |
publish( PingEventPackage.INSTANCE ); |
|
40 |
+ |
} |
|
41 |
+ |
} ); |
|
42 |
+ |
} |
|
43 |
+ |
|
|
44 |
+ |
// todo: Client -> Server of Exception 'e': mEventBus.getTypeNameOf(e), + ":" + e.getMessage() |
|
45 |
+ |
} |