修改在android sdk 在低版本中一个兼容问题

This commit is contained in:
远方夕阳 2019-06-03 17:00:39 +08:00
parent 18e7464051
commit 42ade1ada8
3 changed files with 13 additions and 8 deletions

View File

@ -25,7 +25,6 @@ import java.io.IOException;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectionKey; import java.nio.channels.SelectionKey;
import java.nio.channels.Selector; import java.nio.channels.Selector;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
@ -197,12 +196,14 @@ class CIMConnectorManager{
} }
}catch(ConnectException ignore){ }catch(ConnectException ignore){
IOLOCK.unlock();
handleConnectAbortedEvent(); handleConnectAbortedEvent();
}catch(IllegalArgumentException ignore){ }catch(IllegalArgumentException ignore){
IOLOCK.unlock();
handleConnectAbortedEvent(); handleConnectAbortedEvent();
}catch(IOException ignore) { }catch(IOException ignore) {
handelDisconnectedEvent(); handelDisconnectedEvent();
}catch(ClosedSelectorException ignore) {} }
} }
}); });
} }
@ -407,11 +408,10 @@ class CIMConnectorManager{
} }
} }
if(result == -1) { if(result == -1 && !readBuffer.hasRemaining()) {
closeSession(); closeSession();
return; return;
} }
markLastReadTime(); markLastReadTime();
@ -436,6 +436,11 @@ class CIMConnectorManager{
} }
this.messageReceived(message); this.messageReceived(message);
if(result == -1) {
closeSession();
return;
}
} }

View File

@ -118,7 +118,7 @@ public class CIMLogger {
try { try {
if (session.socket().getLocalAddress() != null) { if (session.socket().getLocalAddress() != null) {
builder.append(" L:").append(session.socket().getLocalAddress().toString()); builder.append(" L:").append(session.socket().getLocalAddress()+":"+session.socket().getLocalPort());
} }
} catch (Exception ignore) { } catch (Exception ignore) {
} }