Multi peer connection that tries all nodes one after another. It can send the command to more than one node in parallel and return the first success if 'parallel' i > 1.

It uses the Nodes class to manage which nodes will be contacted.

### Hierarchy

- RosterWSConnection

### Implements

- IConnection

## Index

### Constructors

- constructor

### Properties

- connNbr
- msgNbr
- nodes
- parallel
- rID
- service
- defaultParallel
- nodes
- totalConnNbr

### Methods

- copy
- getURL
- invalidate
- send
- sendStream
- setParallel
- setRoster
- setTimeout

## Constructors

### constructor

- new RosterWSConnection(r: Roster | string, service: string, parallel?: number): RosterWSConnection

- - Defined in src/network/rosterwsconnection.ts:25

  #### Parameters

  - ##### r: Roster | string

    The roster to use or the rID of the Nodes

  - ##### service: string

    The name of the service to reach

  - ##### Default value parallel: number = RosterWSConnection.defaultParallel

    How many nodes to contact in parallel. Can be changed afterwards

  #### Returns RosterWSConnection

## Properties

### Private connNbr

connNbr: number

- Defined in src/network/rosterwsconnection.ts:22

### Private msgNbr

msgNbr: number = 0

- Defined in src/network/rosterwsconnection.ts:23

### nodes

nodes: Nodes

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

### Private parallel

parallel: number

- Defined in src/network/rosterwsconnection.ts:24

### Private rID

rID: string

- Defined in src/network/rosterwsconnection.ts:25

### Private service

service: string

- Defined in src/network/rosterwsconnection.ts:32

The name of the service to reach

### Static defaultParallel

defaultParallel: number = 3

- Defined in src/network/rosterwsconnection.ts:17

### Static Private nodes

nodes: Map<string, Nodes> = new Map<string, Nodes>()

- Defined in src/network/rosterwsconnection.ts:20

### Static Private totalConnNbr

totalConnNbr: number = 0

- Defined in src/network/rosterwsconnection.ts:19

## Methods

### copy

- copy(service: string): RosterWSConnection

- Implementation of IConnection.copy

  - Defined in src/network/rosterwsconnection.ts:137

  Return a new RosterWSConnection for the given service.

  #### Parameters

  - ##### service: string

  #### Returns RosterWSConnection

### getURL

- getURL(): string

- Implementation of IConnection.getURL

  - Defined in src/network/rosterwsconnection.ts:115

  To be conform with an IConnection

  #### Returns string

### invalidate

- invalidate(address: string): void

- - Defined in src/network/rosterwsconnection.ts:145

  Invalidate a given address.

  #### Parameters

  - ##### address: string

  #### Returns void

### send

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

- Implementation of IConnection.send

  - Defined in src/network/rosterwsconnection.ts:70

  Sends a message to conodes in parallel. As soon as one of the conodes returns success, the message is returned. If a conode returns an error (or times out), a next conode from this.addresses is contacted. If all conodes return an error, the promise is rejected.

  #### Type parameters

  - #### T: Message

  #### Parameters

  - ##### message: Message

    the message to send

  - ##### reply: Message

    the type of the message to return

  #### Returns Promise<T>

### sendStream

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

- Implementation of IConnection.sendStream

  - Defined in src/network/rosterwsconnection.ts:127

  Send a message to the distant peer

  #### Type parameters

  - #### T: Message

  #### Parameters

  - ##### message: Message

  - ##### reply: Message

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

### setParallel

- setParallel(p: number): void

- Implementation of IConnection.setParallel

  - Defined in src/network/rosterwsconnection.ts:54

  Set a new parameter for how many nodes should be contacted in parallel.

  #### Parameters

  - ##### p: number

  #### Returns void

### setRoster

- setRoster(r: Roster): void

- - Defined in src/network/rosterwsconnection.ts:153

  Update roster for this connection.

  #### Parameters

  - ##### r: Roster

  #### Returns void

### setTimeout

- setTimeout(value: number): void

- Implementation of IConnection.setTimeout

  - Defined in src/network/rosterwsconnection.ts:122

  To be conform with an IConnection - sets the timeout on all connections.

  #### Parameters

  - ##### value: number

  #### Returns void

Generated using TypeDoc