@Test public void handleHandshake() { final HelloResponse response = server.handleHandshake(new HelloMessageImpl()); assertThat(response.getUAID(), is(notNullValue())); }
@Override public HelloResponse handleHandshake(final HelloMessage handshake) { final Set<String> oldChannels = store.getChannelIds(handshake.getUAID()); for (String channelId : handshake.getChannelIds()) { if (!oldChannels.contains(channelId)) { store.saveChannel(new DefaultChannel(handshake.getUAID(), channelId, generateEndpointToken(handshake.getUAID(), channelId))); } else { oldChannels.remove(channelId); } } store.removeChannels(oldChannels); return new HelloResponseImpl(handshake.getUAID()); }
DefaultSimplePushServer implements SimplePushServer { @Override public HelloResponse handleHandshake(final HelloMessage handshake) { final Set<String> oldChannels = store.getChannelIds(handshake.getUAID()); for (String channelId : handshake.getChannelIds()) { if (!oldChannels.contains(channelId)) { store.saveChannel(new DefaultChannel(handshake.getUAID(), channelId, generateEndpointToken(handshake.getUAID(), channelId))); } else { oldChannels.remove(channelId); } } store.removeChannels(oldChannels); return new HelloResponseImpl(handshake.getUAID()); } }
DefaultSimplePushServer implements SimplePushServer { @Override public HelloResponse handleHandshake(final HelloMessage handshake) { final Set<String> oldChannels = store.getChannelIds(handshake.getUAID()); for (String channelId : handshake.getChannelIds()) { if (!oldChannels.contains(channelId)) { store.saveChannel(new DefaultChannel(handshake.getUAID(), channelId, generateEndpointToken(handshake.getUAID(), channelId))); } else { oldChannels.remove(channelId); } } store.removeChannels(oldChannels); return new HelloResponseImpl(handshake.getUAID()); } DefaultSimplePushServer(final DataStore store, final SimplePushServerConfig config, final byte[] privateKey); }
DefaultSimplePushServer implements SimplePushServer { @Override public HelloResponse handleHandshake(final HelloMessage handshake) { final Set<String> oldChannels = store.getChannelIds(handshake.getUAID()); for (String channelId : handshake.getChannelIds()) { if (!oldChannels.contains(channelId)) { store.saveChannel(new DefaultChannel(handshake.getUAID(), channelId, generateEndpointToken(handshake.getUAID(), channelId))); } else { oldChannels.remove(channelId); } } store.removeChannels(oldChannels); return new HelloResponseImpl(handshake.getUAID()); } DefaultSimplePushServer(final DataStore store, final SimplePushServerConfig config, final byte[] privateKey); @Override HelloResponse handleHandshake(final HelloMessage handshake); @Override RegisterResponse handleRegister(final RegisterMessage register, final String uaid); @Override Notification handleNotification(final String endpointToken, final String body); @Override UnregisterResponse handleUnregister(final UnregisterMessage unregister, final String uaid); @Override Set<Ack> handleAcknowledgement(final AckMessage ackMessage, final String uaid); @Override Set<Ack> getUnacknowledged(final String uaid); String getUAID(final String channelId); Channel getChannel(final String channelId); boolean hasChannel(final String uaid, final String channelId); boolean removeChannel(final String channnelId, final String uaid); @Override void removeAllChannels(final String uaid); @Override SimplePushServerConfig config(); static byte[] generateAndStorePrivateKey(final DataStore store, final SimplePushServerConfig config); }
DefaultSimplePushServer implements SimplePushServer { @Override public HelloResponse handleHandshake(final HelloMessage handshake) { final Set<String> oldChannels = store.getChannelIds(handshake.getUAID()); for (String channelId : handshake.getChannelIds()) { if (!oldChannels.contains(channelId)) { store.saveChannel(new DefaultChannel(handshake.getUAID(), channelId, generateEndpointToken(handshake.getUAID(), channelId))); } else { oldChannels.remove(channelId); } } store.removeChannels(oldChannels); return new HelloResponseImpl(handshake.getUAID()); } DefaultSimplePushServer(final DataStore store, final SimplePushServerConfig config, final byte[] privateKey); @Override HelloResponse handleHandshake(final HelloMessage handshake); @Override RegisterResponse handleRegister(final RegisterMessage register, final String uaid); @Override Notification handleNotification(final String endpointToken, final String body); @Override UnregisterResponse handleUnregister(final UnregisterMessage unregister, final String uaid); @Override Set<Ack> handleAcknowledgement(final AckMessage ackMessage, final String uaid); @Override Set<Ack> getUnacknowledged(final String uaid); String getUAID(final String channelId); Channel getChannel(final String channelId); boolean hasChannel(final String uaid, final String channelId); boolean removeChannel(final String channnelId, final String uaid); @Override void removeAllChannels(final String uaid); @Override SimplePushServerConfig config(); static byte[] generateAndStorePrivateKey(final DataStore store, final SimplePushServerConfig config);  }