A connection allows to send a message to one or more distant peers. It has a default service it is connected to, and can only be used to send messages to that service. To change service, a copy has to be created using the copy method.

### Hierarchy

- IConnection

### Implemented by

- LeaderConnection
- RosterWSConnection
- WebSocketConnection

## Index

### Methods

- copy
- getURL
- send
- sendStream
- setParallel
- setTimeout

## Methods

### copy

- copy(service: string): IConnection

- - Defined in src/network/nodes.ts:39

  Creates a copy of the connection, but usable with the given service.

  #### Parameters

  - ##### service: string

  #### Returns IConnection

### getURL

- getURL(): string

- - Defined in src/network/nodes.ts:27

  Get the origin of the distant address

  #### Returns string

  the address as a string

### send

- send<T>(message: Message, reply: Message): Promise<T>

- - Defined in src/network/nodes.ts:21

  Send a message to the distant peer

  #### Type parameters

  - #### T: Message

  #### Parameters

  - ##### message: Message

    Protobuf compatible message

  - ##### reply: Message

    Protobuf type of the reply

  #### Returns Promise<T>

  a promise resolving with the reply on success, rejecting otherwise

### sendStream

- sendStream<T>(message: Message, reply: Message): Observable<[T, WebSocketAdapter]>

- - Defined in src/network/nodes.ts:46

  Send a message to the distant peer

  #### Type parameters

  - #### T: Message

  #### Parameters

  - ##### message: Message

    Protobuf compatible message

  - ##### reply: Message

    Protobuf type of the reply

  #### Returns Observable<[T, WebSocketAdapter]>

### setParallel

- setParallel(p: number): void

- - Defined in src/network/nodes.ts:55

  Sets how many nodes will be contacted in parallel

  deprecated
    - don't use IConnection for that, but rather directly a RosterWSConnection.

  #### Parameters

  - ##### p: number

    number of nodes to contact in parallel

  #### Returns void

### setTimeout

- setTimeout(value: number): void

- - Defined in src/network/nodes.ts:33

  Set the timeout value for new connections

  #### Parameters

  - ##### value: number

    Timeout in milliseconds

  #### Returns void

Generated using TypeDoc