use of com.mobiledgex.matchingengine.edgeeventsconfig.EdgeEventsConfig in project edge-cloud-sampleapps by mobiledgex.
the class MainActivity method onResume.
@Override
public void onResume() {
super.onResume();
if (mRpUtil.getNeededPermissions(this).size() > 0) {
// Opens a UI. When it returns, onResume() is called again.
mRpUtil.requestMultiplePermissions(this);
return;
}
if (me == null) {
// ! [matchingengine_constructor]
// Permissions must be available. Check permissions upon OnResume(). Create a MobiledgeX MatchingEngine instance.
me = new MatchingEngine(this);
// ! [matchingengine_constructor]
// ! [enable_edgeevents]
// Register the class subscribing to EdgeEvents to the EdgeEventsBus (Guava EventBus interface).
// default is true.
me.setEnableEdgeEvents(true);
// ! [enable_edgeevents]
// ! [edgeevents_subsscriber_setup_example]
mEdgeEventsSubscriber = new EdgeEventsSubscriber();
me.getEdgeEventsBus().register(mEdgeEventsSubscriber);
// set a default config.
// There is also a parameterized version to further customize.
EdgeEventsConfig backgroundEdgeEventsConfig = me.createDefaultEdgeEventsConfig();
backgroundEdgeEventsConfig.latencyTestType = NetTest.TestType.CONNECT;
// This is the internal port, that has not been remapped to a public port for a particular appInst.
// 0 will favor the first TCP port if found for connect test.
backgroundEdgeEventsConfig.latencyInternalPort = 3765;
// Latency config. There is also a very similar location update config.
// Default is 0, which means test forever.
backgroundEdgeEventsConfig.latencyUpdateConfig.maxNumberOfUpdates = 0;
// The default is 30.
backgroundEdgeEventsConfig.latencyUpdateConfig.updateIntervalSeconds = 7;
backgroundEdgeEventsConfig.latencyThresholdTrigger = 186;
// ! [edgeevents_subsscriber_setup_example]
// backgroundEdgeEventsConfig.latencyUpdateConfig = null;
// backgroundEdgeEventsConfig.locationUpdateConfig = null; // app driven.
// ! [startedgeevents_example]
me.startEdgeEvents(backgroundEdgeEventsConfig);
// ! [startedgeevents_example]
}
if (mDoLocationUpdates) {
startLocationUpdates();
}
}
use of com.mobiledgex.matchingengine.edgeeventsconfig.EdgeEventsConfig in project edge-cloud-sampleapps by mobiledgex.
the class MainActivity method startEdgeEvents.
private void startEdgeEvents() {
mEdgeEventsSubscriber = new EdgeEventsSubscriber();
matchingEngine.getEdgeEventsBus().register(mEdgeEventsSubscriber);
// set a default config.
// There is also a parameterized version to further customize.
EdgeEventsConfig backgroundEdgeEventsConfig = matchingEngine.createDefaultEdgeEventsConfig();
// Modify the default config with a few custom attribute values:
backgroundEdgeEventsConfig.latencyTestType = NetTest.TestType.CONNECT;
// This is the internal port, that has not been remapped to a public port for a particular appInst.
// 0 will grab first UDP port but will favor the first TCP port if found.
backgroundEdgeEventsConfig.latencyInternalPort = 8008;
// Latency config. There is also a very similar location update config.
// Default is 0, which means test forever.
backgroundEdgeEventsConfig.latencyUpdateConfig.maxNumberOfUpdates = 0;
// The default is 30.
backgroundEdgeEventsConfig.latencyUpdateConfig.updateIntervalSeconds = 7;
backgroundEdgeEventsConfig.latencyThresholdTrigger = 186;
String message = "Subscribed to ServerEdgeEvents";
Log.i(TAG, message);
mEventLogViewer.showMessage(message);
}
Aggregations