Skip to content

Commit

Permalink
feat(lib): make listener optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Jun 25, 2024
1 parent 6b2ab1d commit 87d1181
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ interface SocketListener {
* @param streamId the value set to [SockOpt.STREAMID] option set on the peer side
* @return return 0, if the connection is to be accepted. If you return -1, this will be understood as a request to reject the incoming connection.
*/
fun onListen(ns: Socket, hsVersion: Int, peerAddress: InetSocketAddress, streamId: String): Int
fun onListen(
ns: Socket,
hsVersion: Int,
peerAddress: InetSocketAddress,
streamId: String
): Int = 0

/**
* Called just after a pending connection in the background has been resolved and the connection has failed.
Expand All @@ -48,5 +53,10 @@ interface SocketListener {
* @param token the token value, if it was used for group connection, otherwise -1
* @return return 0, if the connection is to be accepted. If you return -1, this will be understood as a request to reject the incoming connection.
*/
fun onConnectionLost(ns: Socket, error: ErrorType, peerAddress: InetSocketAddress, token: Int)
fun onConnectionLost(
ns: Socket,
error: ErrorType,
peerAddress: InetSocketAddress,
token: Int
) = Unit
}

0 comments on commit 87d1181

Please sign in to comment.