Skip to content

Commit

Permalink
Release 1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
teaey committed Mar 12, 2017
1 parent 93c0592 commit e415e8d
Show file tree
Hide file tree
Showing 8 changed files with 491 additions and 12 deletions.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
</developers>

<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.5.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
<version>4.1.5.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/cn/teaey/apns4j/network/AbstractChannel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cn.teaey.apns4j.network;

/**
* @author teaey(xiaofei.wxf)
* @since 0.0.1
*/
public abstract class AbstractChannel implements Channel {
}
15 changes: 7 additions & 8 deletions src/main/java/cn/teaey/apns4j/network/ApnsChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
* @since 1.0.3
*/
public class ApnsChannel implements Channel, PayloadSender<ApnsPayload> {
//private static final Logger log = LoggerFactory.getLogger(ApnsChannel.class);
public static final int DEFAULT_TRY_TIMES = 3;
private static final int CACHE_SIZE = 2000;
private static final AtomicInteger COUNTER = new AtomicInteger(0);
Expand Down Expand Up @@ -130,7 +129,7 @@ public ApnsFuture send(byte[] deviceTokenBytes, ApnsPayload apnsPayload, int try
break;
} catch (IOException e) {
try {
_close();
_closeSocket();
} catch (IOException e1) {
}
//log.error("Failed send payload : {} to device : {} try : {}", new Object[]{jsonString, deviceTokenBytes, e});
Expand Down Expand Up @@ -192,7 +191,7 @@ public ErrorResp recvErrorResp() {
}
byte[] data = new byte[6];
recv(data);
_close();
_closeSocket();
return new ErrorResp(data);
} catch (ApnsException e) {
throw e;
Expand All @@ -201,7 +200,7 @@ public ErrorResp recvErrorResp() {
}
}

private void _close() throws IOException {
private void _closeSocket() throws IOException {
if (null != socket) {
try {
socket.close();
Expand Down Expand Up @@ -250,7 +249,7 @@ public void run() {
public void close() {
try {
if (this.closed.compareAndSet(false, true)) {
_close();
_closeSocket();
}
} catch (IOException e) {
throw new ApnsException(e);
Expand All @@ -273,7 +272,7 @@ public void send(byte[] data) {
out().write(data);
} catch (IOException e) {
try {
_close();
_closeSocket();
} catch (IOException e1) {
}
throw new ApnsException(e);
Expand All @@ -290,7 +289,7 @@ public int recv(byte[] data) {
return in().read(data);
} catch (IOException e) {
try {
_close();
_closeSocket();
} catch (IOException e1) {
}
throw new ApnsException(e);
Expand All @@ -306,7 +305,7 @@ protected void socket() throws IOException {
if (null != socket && null != in && null != out && !socket.isClosed()) {
return;
} else {
_close();
_closeSocket();
this.socket = socketFactory.createSocket();
this.in = socket.getInputStream();
this.out = socket.getOutputStream();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/teaey/apns4j/network/ApnsChannelFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public SecuritySocketFactory getSecuritySocketFactory() {
return securitySocketFactory;
}

public ApnsChannel newChannel() {
return new ApnsChannel(this.securitySocketFactory);
public ApnsNettyChannel newChannel() {
return new ApnsNettyChannel(this.securitySocketFactory);
}

public ApnsChannel newChannel(int tryTimes) {
Expand Down
Loading

0 comments on commit e415e8d

Please sign in to comment.