use of org.eclipse.leshan.server.registration.RegistrationListener in project leshan by eclipse.
the class RedisIntegrationTestHelper method createServer.
@Override
public void createServer() {
LeshanServerBuilder builder = new LeshanServerBuilder();
StaticModelProvider modelProvider = new StaticModelProvider(createObjectModels());
builder.setObjectModelProvider(modelProvider);
DefaultLwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
builder.setDecoder(decoder);
builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
builder.setSecurityStore(new InMemorySecurityStore());
// Create redis store
String redisURI = System.getenv("REDIS_URI");
if (redisURI == null)
redisURI = "";
Pool<Jedis> jedis = new JedisPool(redisURI);
builder.setRegistrationStore(new RedisRegistrationStore(jedis));
// Build server !
server = builder.build();
// monitor client registration
resetLatch();
server.getRegistrationService().addListener(new RegistrationListener() {
@Override
public void updated(RegistrationUpdate update, Registration updatedRegistration, Registration previousRegistration) {
if (updatedRegistration.getEndpoint().equals(getCurrentEndpoint())) {
updateLatch.countDown();
}
}
@Override
public void unregistered(Registration registration, Collection<Observation> observations, boolean expired, Registration newReg) {
if (registration.getEndpoint().equals(getCurrentEndpoint())) {
deregisterLatch.countDown();
}
}
@Override
public void registered(Registration registration, Registration previousReg, Collection<Observation> previousObsersations) {
if (registration.getEndpoint().equals(getCurrentEndpoint())) {
last_registration = registration;
registerLatch.countDown();
}
}
});
}
use of org.eclipse.leshan.server.registration.RegistrationListener in project leshan by eclipse.
the class IntegrationTestHelper method setupRegistrationMonitoring.
protected void setupRegistrationMonitoring() {
resetLatch();
server.getRegistrationService().addListener(new RegistrationListener() {
@Override
public void updated(RegistrationUpdate update, Registration updatedRegistration, Registration previousRegistration) {
if (updatedRegistration.getEndpoint().equals(currentEndpointIdentifier.get())) {
updateLatch.countDown();
}
}
@Override
public void unregistered(Registration registration, Collection<Observation> observations, boolean expired, Registration newReg) {
if (registration.getEndpoint().equals(currentEndpointIdentifier.get())) {
deregisterLatch.countDown();
}
}
@Override
public void registered(Registration registration, Registration previousReg, Collection<Observation> previousObsersations) {
if (registration.getEndpoint().equals(currentEndpointIdentifier.get())) {
last_registration = registration;
registerLatch.countDown();
}
}
});
}
use of org.eclipse.leshan.server.registration.RegistrationListener in project leshan by eclipse.
the class RedisSecureIntegrationTestHelper method createServer.
@Override
public void createServer() {
LeshanServerBuilder builder = new LeshanServerBuilder();
StaticModelProvider modelProvider = new StaticModelProvider(createObjectModels());
builder.setObjectModelProvider(modelProvider);
DefaultLwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
builder.setDecoder(decoder);
builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
// Create redis store
String redisURI = System.getenv("REDIS_URI");
if (redisURI == null)
redisURI = "";
Pool<Jedis> jedis = new JedisPool(redisURI);
builder.setRegistrationStore(new RedisRegistrationStore(jedis));
builder.setSecurityStore(new RedisSecurityStore(jedis));
// Build server !
server = builder.build();
// monitor client registration
resetLatch();
server.getRegistrationService().addListener(new RegistrationListener() {
@Override
public void updated(RegistrationUpdate update, Registration updatedRegistration, Registration previousRegistration) {
if (updatedRegistration.getEndpoint().equals(getCurrentEndpoint())) {
updateLatch.countDown();
}
}
@Override
public void unregistered(Registration registration, Collection<Observation> observations, boolean expired, Registration newReg) {
if (registration.getEndpoint().equals(getCurrentEndpoint())) {
deregisterLatch.countDown();
}
}
@Override
public void registered(Registration registration, Registration previousReg, Collection<Observation> previousObsersations) {
if (registration.getEndpoint().equals(getCurrentEndpoint())) {
last_registration = registration;
registerLatch.countDown();
}
}
});
}
Aggregations