dwrtc / ch.hsr.dsl.dwrtc.signaling / ClientService

ClientService

class ClientService : IClientService

Connection to the P2P network.

Types

Companion

companion object Companion : KLogging

Logging companion

Constructors

<init>

ClientService(bootstrapPeerAddress: PeerAddress, peerPort: Int? = findFreePort())

Creates a peer and bootstraps with a given TomP2P Peer Address. Optionally, set the port this peer uses.

ClientService(bootstrapPeers: List<PeerConnectionDetails>, peerPort: Int?)

Creates a peer and bootstraps with a given IP/port pair. Optionally, set the port this peer uses.

ClientService(peerPort: Int? = findFreePort())

Creates a peer. Optionally, set the port this peer uses

Properties

bootstrapPeers

var bootstrapPeers: List<PeerConnectionDetails>

Peers used for bootstrapping

emitterMap

val emitterMap: ConcurrentHashMap<String, (ExternalClient, ClientMessage) -> Unit>

Map of user's session ID to their message handlers. See InternalClient.onReceiveMessage

peer

internal var peer: PeerDHT

The TomP2P peer

peerId

val peerId: String

The peer's ID

Functions

addClient

fun addClient(sessionId: String): Pair<IInternalClient, Future>

Add a new user.

addDirectMessageListener

fun addDirectMessageListener(sessionId: String, emitter: (IExternalClient, ClientMessage) -> Unit): Unit

Add a direct message listener. See InternalClient.onReceiveMessage

bootstrapPeer

fun bootstrapPeer(peerAddress: PeerAddress): Unit

Bootstrap our peer to another peer. Only used for testing!

bootstrapPeers

fun bootstrapPeers(peersDetails: List<PeerConnectionDetails>): Unit

Bootstrap our peer to another peer

findClient

fun findClient(sessionId: String): GetFuture<IExternalClient>

Find another user

removeClient

fun removeClient(client: IInternalClient): Future

Remove a user.

setupDirectMessageListener

fun setupDirectMessageListener(): Unit

Setup the dispatcher to send the incoming messages to the correct user