Skip to content

Commit cc8aad3

Browse files
authored
Merge pull request carlosCharz#2 from kicktipp/master
Issue 1: Let Project compile and run under Java 1.7
2 parents 1fa1665 + 0b4bfe9 commit cc8aad3

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55
<groupId>com.wedevol</groupId>
66
<artifactId>xmppserver2</artifactId>
7-
<version>0.0.1</version>
7+
<version>0.0.2-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>FCM XMPP Server</name>
1111
<url>http://maven.apache.org</url>
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<maven.compiler.source>1.7</maven.compiler.source>
16+
<maven.compiler.target>1.7</maven.compiler.target>
1517
</properties>
1618

1719
<dependencies>

src/main/java/com/wedevol/xmpp/server/CcsClient.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
import org.jivesoftware.smack.StanzaListener;
1717
import org.jivesoftware.smack.XMPPConnection;
1818
import org.jivesoftware.smack.XMPPException;
19+
import org.jivesoftware.smack.filter.StanzaFilter;
1920
import org.jivesoftware.smack.packet.Stanza;
2021
import org.jivesoftware.smack.provider.ExtensionElementProvider;
2122
import org.jivesoftware.smack.provider.ProviderManager;
23+
import org.jivesoftware.smack.sm.predicates.ForEveryStanza;
2224
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
2325
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
2426
import org.json.simple.JSONValue;
@@ -157,11 +159,20 @@ public void connected(XMPPConnection arg0) {
157159
});
158160

159161
// Handle incoming packets (the class implements the StanzaListener)
160-
connection.addAsyncStanzaListener(this,
161-
stanza -> stanza.hasExtension(Util.FCM_ELEMENT_NAME, Util.FCM_NAMESPACE));
162+
connection.addAsyncStanzaListener(this, new StanzaFilter() {
163+
@Override
164+
public boolean accept(Stanza stanza) {
165+
return stanza.hasExtension(Util.FCM_ELEMENT_NAME, Util.FCM_NAMESPACE);
166+
}
167+
});
162168

163169
// Log all outgoing packets
164-
connection.addPacketInterceptor(stanza -> logger.log(Level.INFO, "Sent: {}", stanza.toXML()), stanza -> true);
170+
connection.addPacketInterceptor(new StanzaListener() {
171+
@Override
172+
public void processPacket(Stanza stanza) throws NotConnectedException {
173+
logger.log(Level.INFO, "Sent: {}", stanza.toXML());
174+
}
175+
}, ForEveryStanza.INSTANCE);
165176

166177
connection.login(fcmServerUsername, mApiKey);
167178
logger.log(Level.INFO, "Logged in: " + fcmServerUsername);

0 commit comments

Comments
 (0)