@Test public void handeRegister() { final RegisterResponse response = server.handleRegister(new RegisterMessageImpl("someChannelId"), UUIDUtil.newUAID()); assertThat(response.getChannelId(), equalTo("someChannelId")); assertThat(response.getMessageType(), equalTo(MessageType.Type.REGISTER)); assertThat(response.getStatus().getCode(), equalTo(200)); assertThat(response.getStatus().getMessage(), equalTo("OK")); assertThat(response.getPushEndpoint().startsWith("http: }
@Override public RegisterResponse handleRegister(final RegisterMessage register, final String uaid) { final String channelId = register.getChannelId(); final String endpointToken = generateEndpointToken(uaid, channelId); final boolean saved = store.saveChannel(new DefaultChannel(uaid, channelId, endpointToken)); final Status status = saved ? new StatusImpl(200, "OK") : new StatusImpl(409, "Conflict: channeld [" + channelId + " is already in use"); return new RegisterResponseImpl(channelId, status, makeEndpointUrl(endpointToken)); }
DefaultSimplePushServer implements SimplePushServer { @Override public RegisterResponse handleRegister(final RegisterMessage register, final String uaid) { final String channelId = register.getChannelId(); final String endpointToken = generateEndpointToken(uaid, channelId); final boolean saved = store.saveChannel(new DefaultChannel(uaid, channelId, endpointToken)); final Status status = saved ? new StatusImpl(200, "OK") : new StatusImpl(409, "Conflict: channeld [" + channelId + " is already in use"); return new RegisterResponseImpl(channelId, status, makeEndpointUrl(endpointToken)); } }
DefaultSimplePushServer implements SimplePushServer { @Override public RegisterResponse handleRegister(final RegisterMessage register, final String uaid) { final String channelId = register.getChannelId(); final String endpointToken = generateEndpointToken(uaid, channelId); final boolean saved = store.saveChannel(new DefaultChannel(uaid, channelId, endpointToken)); final Status status = saved ? new StatusImpl(200, "OK") : new StatusImpl(409, "Conflict: channeld [" + channelId + " is already in use"); return new RegisterResponseImpl(channelId, status, makeEndpointUrl(endpointToken)); } DefaultSimplePushServer(final DataStore store, final SimplePushServerConfig config, final byte[] privateKey); }
DefaultSimplePushServer implements SimplePushServer { @Override public RegisterResponse handleRegister(final RegisterMessage register, final String uaid) { final String channelId = register.getChannelId(); final String endpointToken = generateEndpointToken(uaid, channelId); final boolean saved = store.saveChannel(new DefaultChannel(uaid, channelId, endpointToken)); final Status status = saved ? new StatusImpl(200, "OK") : new StatusImpl(409, "Conflict: channeld [" + channelId + " is already in use"); return new RegisterResponseImpl(channelId, status, makeEndpointUrl(endpointToken)); } 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 RegisterResponse handleRegister(final RegisterMessage register, final String uaid) { final String channelId = register.getChannelId(); final String endpointToken = generateEndpointToken(uaid, channelId); final boolean saved = store.saveChannel(new DefaultChannel(uaid, channelId, endpointToken)); final Status status = saved ? new StatusImpl(200, "OK") : new StatusImpl(409, "Conflict: channeld [" + channelId + " is already in use"); return new RegisterResponseImpl(channelId, status, makeEndpointUrl(endpointToken)); } 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);  }