*/
void readMessages() throws IOException {
if (rxTime==0) {
rxTime = System.currentTimeMillis();
}
MessageInfo info = channel.receive( rxBuffer, null, null );
if (info==null) {
// happens a lot, some sort of keep-alive?
if ( getSIPStack().getStackLogger().isLoggingEnabled( LogWriter.TRACE_DEBUG ) ) {
getSIPStack().getStackLogger().logDebug( "SCTP read-event but no message" );
}
return;
} else if (info.bytes()==-1) {
getSIPStack().getStackLogger().logWarning( "SCTP peer closed, closing too..." );
this.close();
return;
} else if ( !info.isComplete() ) {
if ( getSIPStack().getStackLogger().isLoggingEnabled( LogWriter.TRACE_DEBUG ) ) {
getSIPStack().getStackLogger().logDebug( "SCTP incomplete message; bytes=" + info.bytes() );
}
return;
} else {
if ( getSIPStack().getStackLogger().isLoggingEnabled( LogWriter.TRACE_DEBUG ) ) {
getSIPStack().getStackLogger().logDebug( "SCTP message now complete; bytes=" + info.bytes() );
}
}
// Assume it is 1 full message, not multiple messages
byte[] msg = new byte[ rxBuffer.position() ];