Skip to main content

Work in progress

PrivMX Endpoint Swift is not up to date with the core documentation. Some of the features you've seen described in other parts of the documentation might not be mentioned here. Those changes do not influence compatibility, however

Handling Events

How to subscribe to events, assuming you have already started listening.

Connection

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.core.LibConnectedEvent.self,
from: .platform, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when lib connect
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.core.LibDisconnectedEvent.self,
from: .platform, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when lib disconnects
})

Threads

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.thread.ThreadCreatedEvent.self,
from: .thread, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when new thread created
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.thread.ThreadUpdatedEvent.self,
from: .thread, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when thread updated
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.thread.ThreadStatsChangedEvent.self,
from: .thread, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when thread stats changes
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.thread.ThreadDeletedEvent.self,
from: .thread, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when thread deleted
})

Read more about Thread events.

Stores

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.store.StoreCreatedEvent.self,
from: .store, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when new store created
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.store.StoreUpdatedEvent.self,
from: .store, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when store updated
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.store.StoreStatsChangedEvent.self,
from: .store, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when store stats changes
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.store.StoreDeletedEvent.self,
from: .store, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when store deleted
})

Read more about Store events.

Inboxes

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.inbox.InboxCreatedEvent.self,
from: .inbox, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when new inbox created
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.inbox.InboxUpdatedEvent.self,
from: .inbox, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when inbox updated
})

_ = try? endpointContainer.getEndpoint(endpointId)?.registerCallback(
for: privmx.endpoint.inbox.InboxUpdatedEvent.self,
from: .inbox, identified: "SOME_UNIQUE_IDENTIFIER",
{ eventData in
// some actions when inbox updated
})