@Override public boolean equals(Object other) { return (this == other || (other instanceof SimpSubscription && getId().equals(((SimpSubscription) other).getId()))); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SimpSubscription)) { return false; } SimpSubscription otherSubscription = (SimpSubscription) other; return (getId().equals(otherSubscription.getId()) && ObjectUtils.nullSafeEquals(getSession(), otherSubscription.getSession())); }
/** * Constructor to create DTO from a local user subscription. */ public TransferSimpSubscription(SimpSubscription subscription) { this.id = subscription.getId(); this.session = new TransferSimpSession(); this.destination = subscription.getDestination(); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SimpSubscription)) { return false; } SimpSubscription otherSubscription = (SimpSubscription) other; return (getId().equals(otherSubscription.getId()) && getSession().getId().equals(otherSubscription.getSession().getId())); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SimpSubscription)) { return false; } SimpSubscription otherSubscription = (SimpSubscription) other; return (ObjectUtils.nullSafeEquals(getSession(), otherSubscription.getSession()) && this.id.equals(otherSubscription.getId())); }
@Test public void findSubscriptions() throws Exception { DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry(); TestPrincipal user = new TestPrincipal("joe"); Message<byte[]> message = createMessage(SimpMessageType.CONNECT_ACK, "123"); SessionConnectedEvent event = new SessionConnectedEvent(this, message, user); registry.onApplicationEvent(event); message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub1", "/match"); SessionSubscribeEvent subscribeEvent = new SessionSubscribeEvent(this, message, user); registry.onApplicationEvent(subscribeEvent); message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub2", "/match"); subscribeEvent = new SessionSubscribeEvent(this, message, user); registry.onApplicationEvent(subscribeEvent); message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub3", "/not-a-match"); subscribeEvent = new SessionSubscribeEvent(this, message, user); registry.onApplicationEvent(subscribeEvent); Set<SimpSubscription> matches = registry.findSubscriptions(new SimpSubscriptionMatcher() { @Override public boolean match(SimpSubscription subscription) { return subscription.getDestination().equals("/match"); } }); assertEquals(2, matches.size()); Iterator<SimpSubscription> iterator = matches.iterator(); Set<String> sessionIds = new HashSet<>(2); sessionIds.add(iterator.next().getId()); sessionIds.add(iterator.next().getId()); assertEquals(new HashSet<>(Arrays.asList("sub1", "sub2")), sessionIds); }
@Test public void getUserFromRemoteRegistry() throws Exception { // Prepare broadcast message from remote server TestSimpUser testUser = new TestSimpUser("joe"); TestSimpSession testSession = new TestSimpSession("remote-sess"); testSession.addSubscriptions(new TestSimpSubscription("remote-sub", "/remote-dest")); testUser.addSessions(testSession); SimpUserRegistry testRegistry = mock(SimpUserRegistry.class); when(testRegistry.getUsers()).thenReturn(Collections.singleton(testUser)); Object registryDto = new MultiServerUserRegistry(testRegistry).getLocalRegistryDto(); Message<?> message = this.converter.toMessage(registryDto, null); // Add remote registry this.registry.addRemoteRegistryDto(message, this.converter, 20000); assertEquals(1, this.registry.getUserCount()); SimpUser user = this.registry.getUser("joe"); assertNotNull(user); assertTrue(user.hasSessions()); assertEquals(1, user.getSessions().size()); SimpSession session = user.getSession("remote-sess"); assertNotNull(session); assertEquals("remote-sess", session.getId()); assertSame(user, session.getUser()); assertEquals(1, session.getSubscriptions().size()); SimpSubscription subscription = session.getSubscriptions().iterator().next(); assertEquals("remote-sub", subscription.getId()); assertSame(session, subscription.getSession()); assertEquals("/remote-dest", subscription.getDestination()); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SimpSubscription)) { return false; } SimpSubscription otherSubscription = (SimpSubscription) other; return (getId().equals(otherSubscription.getId()) && ObjectUtils.nullSafeEquals(getSession(), otherSubscription.getSession())); }
/** * Constructor to create DTO from a local user subscription. */ public TransferSimpSubscription(SimpSubscription subscription) { this.id = subscription.getId(); this.session = new TransferSimpSession(); this.destination = subscription.getDestination(); }
@Override public boolean equals(Object other) { return (this == other || (other instanceof SimpSubscription && getId().equals(((SimpSubscription) other).getId()))); }
@Override public boolean equals(Object other) { return (this == other || (other instanceof SimpSubscription && getId().equals(((SimpSubscription) other).getId()))); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SimpSubscription)) { return false; } SimpSubscription otherSubscription = (SimpSubscription) other; return (getId().equals(otherSubscription.getId()) && ObjectUtils.nullSafeEquals(getSession(), otherSubscription.getSession())); }
/** * Constructor to create DTO from a local user subscription. */ public TransferSimpSubscription(SimpSubscription subscription) { this.id = subscription.getId(); this.session = new TransferSimpSession(); this.destination = subscription.getDestination(); }
/** * Constructor to create DTO from a local user subscription. */ public TransferSimpSubscription(SimpSubscription subscription) { this.id = subscription.getId(); this.session = new TransferSimpSession(); this.destination = subscription.getDestination(); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SimpSubscription)) { return false; } SimpSubscription otherSubscription = (SimpSubscription) other; return (getId().equals(otherSubscription.getId()) && ObjectUtils.nullSafeEquals(getSession(), otherSubscription.getSession())); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SimpSubscription)) { return false; } SimpSubscription otherSubscription = (SimpSubscription) other; return (getId().equals(otherSubscription.getId()) && getSession().getId().equals(otherSubscription.getSession().getId())); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SimpSubscription)) { return false; } SimpSubscription otherSubscription = (SimpSubscription) other; return (getId().equals(otherSubscription.getId()) && getSession().getId().equals(otherSubscription.getSession().getId())); }