From 9e5a6b3f2f6907f18f22718bcb6f0ac7f79c95cd Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 12 Apr 2018 14:17:46 +0300 Subject: server: MessageEvent now have list of subscribers --- .../src/main/java/com/juick/components/Notifications.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'juick-notifications/src/main/java/com/juick/components/Notifications.java') diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java index 5f6630fb..ce89de32 100644 --- a/juick-notifications/src/main/java/com/juick/components/Notifications.java +++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java @@ -22,7 +22,6 @@ import com.google.android.gcm.server.*; import com.juick.ExternalToken; import com.juick.User; import com.juick.formatters.PlainTextFormatter; -import com.juick.server.component.MessageEvent; import com.juick.util.MessageUtils; import com.turo.pushy.apns.ApnsClient; import com.turo.pushy.apns.PushNotificationResponse; @@ -33,7 +32,6 @@ import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationListener; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpMethod; import org.springframework.stereotype.Component; @@ -41,6 +39,7 @@ import org.springframework.web.client.RestTemplate; import javax.annotation.Nonnull; import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; import javax.inject.Inject; import java.io.IOException; import java.util.*; @@ -52,7 +51,7 @@ import java.util.stream.Collectors; * @author Ugnich Anton */ @Component -public class Notifications implements NotificationClientListener, AutoCloseable, ApplicationListener { +public class Notifications implements NotificationClientListener { private static Logger logger = LoggerFactory.getLogger(Notifications.class); @Inject @@ -78,9 +77,7 @@ public class Notifications implements NotificationClientListener, AutoCloseable, public void init() throws IOException { mpnsClient.setListener(this); } - @Override - public void onApplicationEvent(@Nonnull MessageEvent event) { - com.juick.Message jmsg = event.getMessage(); + public void messageReceived(@Nonnull com.juick.Message jmsg) { User pmTo = jmsg.getTo(); final List users = new ArrayList<>(); @@ -205,7 +202,7 @@ public class Notifications implements NotificationClientListener, AutoCloseable, } } - @Override + @PreDestroy public void close() throws Exception { apns.close(); -- cgit v1.2.3