本文整理汇总了Java中com.pusher.client.PusherOptions类的典型用法代码示例。如果您正苦于以下问题:Java PusherOptions类的具体用法?Java PusherOptions怎么用?Java PusherOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PusherOptions类属于com.pusher.client包,在下文中一共展示了PusherOptions类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PusherClient
import com.pusher.client.PusherOptions; //导入依赖的package包/类
public PusherClient(String key) {
channels = new HashMap<>();
PusherOptions options = new PusherOptions();
pusher = new Pusher(key, options);
pusher.connect(new ConnectionEventListener() {
@Override
public void onConnectionStateChange(ConnectionStateChange change) {
log("State changed from " + change.getPreviousState() + " to " + change.getCurrentState());
}
@Override
public void onError(String message, String code, Exception e) {
log("Error: " + message + " (" + code + ")");
}
}, ConnectionState.ALL);
}
示例2: testInitializeNotificationService_Success
import com.pusher.client.PusherOptions; //导入依赖的package包/类
@Test
public void testInitializeNotificationService_Success() throws Exception {
PusherOptions mockPusherOptions = PowerMockito.mock(PusherOptions.class);
Pusher mockPusher = PowerMockito.mock(Pusher.class);
Channel mockChannel = Mockito.mock(Channel.class);
PowerMockito.whenNew(PusherOptions.class).withNoArguments().thenReturn(mockPusherOptions);
Mockito.when(mockPusherOptions.setCluster(Mockito.anyString())).thenReturn(mockPusherOptions);
Mockito.when(mockPusherOptions.setActivityTimeout(Mockito.anyLong())).thenReturn(mockPusherOptions);
PowerMockito.whenNew(Pusher.class).withArguments(Mockito.anyString(), Mockito.isA(PusherOptions.class)).thenReturn(mockPusher);
Mockito.doNothing().when(mockPusher).connect(Mockito.isA(ConnectionEventListener.class), Mockito.isA(ConnectionState.class));
Mockito.when(mockPusher.subscribe(Mockito.anyString())).thenReturn(mockChannel);
Mockito.doNothing().when(mockChannel).bind(Mockito.anyString(), Mockito.isA(SubscriptionEventListener.class));
boolean result = pusherNotificationService.initializeNotificationService(getPlatformAuthDetailsResponseVO);
assertThat(result).isTrue();
PowerMockito.verifyNew(PusherOptions.class).withNoArguments();
Mockito.verify(mockPusherOptions, Mockito.times(1)).setCluster(Mockito.anyString());
Mockito.verify(mockPusherOptions, Mockito.times(1)).setActivityTimeout(Mockito.anyLong());
PowerMockito.verifyNew(Pusher.class).withArguments(Mockito.anyString(), Mockito.isA(PusherOptions.class));
Mockito.verify(mockPusher).connect(Mockito.isA(ConnectionEventListener.class), Mockito.isA(ConnectionState.class));
Mockito.verify(mockPusher, Mockito.times(1)).subscribe(Mockito.anyString());
Mockito.verify(mockChannel, Mockito.atLeastOnce()).bind(Mockito.anyString(), Mockito.isA(SubscriptionEventListener.class));
}
示例3: subscribe
import com.pusher.client.PusherOptions; //导入依赖的package包/类
private void subscribe() {
String apiKey = "cb65d0a7a72cd94adf1f";
PusherOptions options = new PusherOptions().setEncrypted(true);
Pusher pusher = new Pusher(apiKey, options);
pusher.connect(this);
// Subscribe to tickers
pusher.subscribe("ticker.3", this, eventName); // LTC / BTC
pusher.subscribe("ticker.132", this, eventName); // DOGE / BTC
pusher.subscribe("ticker.155", this, eventName); // DRK / BTC
// Keep main thread asleep while we watch for events or application will terminate
while (!stop) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
示例4: onCreate
import com.pusher.client.PusherOptions; //导入依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
TextView versionView = (TextView)findViewById(R.id.label_version);
versionView.setText("pusher-java-client version: " + PusherOptions.LIB_VERSION);
versionView.invalidate();
}
示例5: setOptions
import com.pusher.client.PusherOptions; //导入依赖的package包/类
/** Options for the Pusher client library to use. */
public PusherBuilder setOptions(PusherOptions options) {
this.options = options;
return this;
}
示例6: PusherBinder
import com.pusher.client.PusherOptions; //导入依赖的package包/类
public PusherBinder(Client client, String key, String region)
{
PusherOptions options = new PusherOptions();
options.setCluster(region);
Pusher pusher = new Pusher(key, options);
pusher.connect();
channel = pusher.subscribe(client.getGame());
}