Code cleanup
This commit is contained in:
parent
ace2ac453b
commit
55737c41c3
@ -42,8 +42,13 @@ import java.util.concurrent.*
|
|||||||
open class Connection(connectionParameters: ConnectionParams<*>) {
|
open class Connection(connectionParameters: ConnectionParams<*>) {
|
||||||
private var messageHandler: FragmentAssembler
|
private var messageHandler: FragmentAssembler
|
||||||
|
|
||||||
private val subscription = connectionParameters.connectionInfo.sub
|
/**
|
||||||
private val publication = connectionParameters.connectionInfo.pub
|
* the endpoint associated with this connection
|
||||||
|
*/
|
||||||
|
internal val endPoint = connectionParameters.endPoint
|
||||||
|
|
||||||
|
internal val subscription = info.sub
|
||||||
|
internal val publication = info.pub
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When publishing data, we cannot have concurrent publications for a single connection (per Aeron publication)
|
* When publishing data, we cannot have concurrent publications for a single connection (per Aeron publication)
|
||||||
@ -66,39 +71,40 @@ open class Connection(connectionParameters: ConnectionParams<*>) {
|
|||||||
/**
|
/**
|
||||||
* The unique session id of this connection, assigned by the server.
|
* The unique session id of this connection, assigned by the server.
|
||||||
*
|
*
|
||||||
* Specifically this is the subscription session ID of the server
|
* Specifically this is the subscription session ID for the server
|
||||||
*/
|
*/
|
||||||
val id = connectionParameters.connectionInfo.sessionIdSub
|
val id = if (endPoint::class.java == Client::class.java) {
|
||||||
|
info.sessionIdPub
|
||||||
|
} else {
|
||||||
|
info.sessionIdSub
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The remote address, as a string. Will be null for IPC connections
|
* The remote address, as a string. Will be null for IPC connections
|
||||||
*/
|
*/
|
||||||
val remoteAddress = connectionParameters.connectionInfo.remoteAddress
|
val remoteAddress = info.remoteAddress
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The remote address, as a string. Will be "IPC" for IPC connections
|
* The remote address, as a string. Will be "IPC" for IPC connections
|
||||||
*/
|
*/
|
||||||
val remoteAddressString = connectionParameters.connectionInfo.remoteAddressString
|
val remoteAddressString = info.remoteAddressString
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The remote port. Will be 0 for IPC connections
|
* The remote port. Will be 0 for IPC connections
|
||||||
*/
|
*/
|
||||||
val remotePort = connectionParameters.connectionInfo.portPub
|
val remotePort = info.portPub
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if this connection is an IPC connection
|
* @return true if this connection is an IPC connection
|
||||||
*/
|
*/
|
||||||
val isIpc = connectionParameters.connectionInfo.isIpc
|
val isIpc = info.isIpc
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if this connection is a network connection
|
* @return true if this connection is a network connection
|
||||||
*/
|
*/
|
||||||
val isNetwork = !isIpc
|
val isNetwork = !isIpc
|
||||||
|
|
||||||
/**
|
|
||||||
* the endpoint associated with this connection
|
|
||||||
*/
|
|
||||||
internal val endPoint = connectionParameters.endPoint
|
|
||||||
|
|
||||||
|
|
||||||
private val listenerManager = atomic<ListenerManager<Connection>?>(null)
|
private val listenerManager = atomic<ListenerManager<Connection>?>(null)
|
||||||
@ -191,7 +197,6 @@ open class Connection(connectionParameters: ConnectionParams<*>) {
|
|||||||
// * @return the AES key. key=32 byte, iv=12 bytes (AES-GCM implementation).
|
// * @return the AES key. key=32 byte, iv=12 bytes (AES-GCM implementation).
|
||||||
// */
|
// */
|
||||||
// fun cryptoKey(): SecretKey {
|
// fun cryptoKey(): SecretKey {
|
||||||
// TODO()
|
|
||||||
//// return channelWrapper.cryptoKey()
|
//// return channelWrapper.cryptoKey()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -235,8 +240,6 @@ open class Connection(connectionParameters: ConnectionParams<*>) {
|
|||||||
|
|
||||||
val listenerManager = listenerManager.value!!
|
val listenerManager = listenerManager.value!!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (message is MethodResponse && message.result is Exception) {
|
if (message is MethodResponse && message.result is Exception) {
|
||||||
val result = message.result as Exception
|
val result = message.result as Exception
|
||||||
val newException = SerializationException("Error serializing message ${message.javaClass.simpleName}: '$message'", result)
|
val newException = SerializationException("Error serializing message ${message.javaClass.simpleName}: '$message'", result)
|
||||||
|
@ -654,11 +654,6 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
|
|||||||
logger.trace { "[${header.sessionId()}] received: ${message?.javaClass?.simpleName} $message" }
|
logger.trace { "[${header.sessionId()}] received: ${message?.javaClass?.simpleName} $message" }
|
||||||
processMessage(message, connection)
|
processMessage(message, connection)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// we must READ all bytes! If we don't the image won't go away. Kyro eagerly aborted the read!
|
|
||||||
for (i in 0..length) {
|
|
||||||
buffer.getByte(offset+i)
|
|
||||||
}
|
|
||||||
|
|
||||||
listenerManager.notifyError(connection, newException("Error de-serializing message", e))
|
listenerManager.notifyError(connection, newException("Error de-serializing message", e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user