Ditto 4.8.0-rc.2
|
The entrypoint for all actions that relate presence of other peers known by the current peer, either directly or through other peers. More...
Inherits Drop.
Public Member Functions | |
DittoPresenceObserver | Observe (Action< DittoPresenceGraph > callback) |
Request information about Ditto peers in range of this device. This method returns an observer which should be held as long as updates are required. A newly registered observer will have a peers update delivered to it immediately. From then on it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change. | |
DittoPresenceGraph | Exec () |
Request information about Ditto peers in range of this device. | |
void | SetPeerMetadata (Dictionary< string, object > peerMetadata) |
Set arbitrary metadata to be associated with the current peer. | |
void | SetPeerMetadataJsonString (string jsonString) |
Set arbitrary metadata formatted as JSON to be associated with the current peer. | |
Protected Member Functions | |
override void | Dispose (bool disposing) |
Properties | |
Dictionary< string, object > | PeerMetadata [get] |
Metadata associated with the current peer. | |
string | PeerMetadataJsonString [get] |
Metadata associated with the current peer as a JSON string. | |
Func< DittoConnectionRequest, Task< DittoConnectionRequestAuthorization > > | ConnectionRequestHandler [get, set] |
Set this handler to control which peers in a Ditto mesh can connect to the current peer. | |
DittoPresenceGraph | Graph [get] |
Returns the current presence graph capturing all known peers and connections between them. | |
The entrypoint for all actions that relate presence of other peers known by the current peer, either directly or through other peers.
You don't create one directly but can access it from a particular Ditto
instance via its Presence
property.
|
inline |
Request information about Ditto peers in range of this device.
DittoPresenceGraph
instance.
|
inline |
Request information about Ditto peers in range of this device. This method returns an observer which should be held as long as updates are required. A newly registered observer will have a peers update delivered to it immediately. From then on it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change.
callback | The Action that will be invoked when there is a presence update. |
DittoPeersObserver
instance, which must be retained to continue receiving callback updates.
|
inline |
Set arbitrary metadata to be associated with the current peer.
The metadata must not exceed 4 KB in size when JSON-encoded.
This is a convenience method that wraps SetPeerMetadataJsonString(string)(byte[])
peerMetadata | A dictionary containing metadata.Keys must be strings and values must be JSON-compatible. |
DittoNotJsonCompatibleException | If dictionary contains a value that is not JSON-compatible. |
DittoSizeLimitExceededValidationException | If dictionary encoded as JSON exceeds the maximum size as given by 4 KB. |
|
inline |
Set arbitrary metadata formatted as JSON to be associated with the current peer.
The metadata must not exceed 4 KB in size.
jsonString | JSON metadata. |
DittoNotADictionaryValidationException | If jsonData decodes to an object that is not a dictionary. |
DittoSizeLimitExceededValidationException | If dictionary encoded as JSON exceeds the maximum size as given by 4 KB. |
DittoInvalidJsonException | If jsonString is not valid JSON. |
|
getset |
Set this handler to control which peers in a Ditto mesh can connect to the current peer.
Each peer in a Ditto mesh will attempt to connect to other peers that it can reach. By default, the mesh will try and establish connections that optimize for the best overall connectivity between peers. However, you can set this handler to assert some control over which peers you connect to.
If set, this handler is called for every incoming connection request from a remote peer and is passed the other peer's PeerKey
, PeerMetadata
, and IdentityServiceMetadata
. The handler can then accept or reject the request by returning an according DittoConnectionRequestAuthorization value. When the connection request is rejected, the remote peer may retry the connection request after a short delay.
Connection request handlers must reliably respond to requests within a short time. If a handler takes too long to respond or throws an exception, the connection request will be denied. The response currently times out after 10 seconds, but this exact value may be subject to change in future releases.
|
get |
Metadata associated with the current peer.
Other peers in the same mesh can access this user-provided dictionary of metadata via the presence graph at DittoPresence.Graph and when evaluating connection requests using DittoPresence.ConnectionRequestHandler. Use SetPeerMetadata(Dictionary<string, object>) or SetPeerMetadataJsonString(string) to set this value.
This is a convenience property that wraps PeerMetadataJsonString
|
get |
Metadata associated with the current peer as a JSON string.
Other peers in the same mesh can access this user-provided dictionary of metadata via the presence graph at DittoPresence.Graph and when evaluating connection requests using DittoPresence.ConnectionRequestHandler. Use SetPeerMetadata(Dictionary<string, object>) or SetPeerMetadataJsonString(string) to set this value.