Skip to content

Commit

Permalink
Update the async XMPP API proposal (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Sep 1, 2019
1 parent c209b6f commit df4be6f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions Emulsion/Xmpp/AsyncXmppClient.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Emulsion.Xmpp.AsyncXmppClient

open System.Security
open System.Threading

Expand All @@ -12,21 +13,37 @@ type SignInInfo = {
Password: SecureString
}

type Jid = string

type RoomInfo = {
RoomJid: string
RoomJid: Jid
Nickname: string
}

type MessageInfo = {
RecipientJid: string
Text: string
}
type MessageDeliveryInfo = Async<unit> // Resolves after the message is guaranteed to be delivered to the recipient.

type Lifetime = CancellationToken // TODO[F]: Determine a proper lifetime?

type IAsyncXmppClient =
abstract member Connect : ServerInfo -> Async<unit>
abstract member SignIn : SignInInfo -> Async<unit>
/// Establish a connection to the server. Returns a connection lifetime that will terminate if the connection
/// terminates.
abstract member Connect : ServerInfo -> Async<Lifetime>

/// Sign in with the provided credentials. Returns a session lifetime that will terminate if the session terminates.
abstract member SignIn : SignInInfo -> Async<Lifetime>

/// Enter the room, returning the in-room lifetime. Will terminate if kicked or left the room.
abstract member EnterRoom : RoomInfo -> Async<Lifetime>
abstract member SendMessage : Lifetime -> MessageInfo -> Async<unit>

/// Sends the message to the room.
abstract member SendMessage : MessageInfo -> Async<MessageDeliveryInfo>

/// Waits for the message to be delivered.
abstract member AwaitMessageDelivery : MessageDeliveryInfo -> Async<unit>

/// Disconnects from the server (if connected) and frees all the resources associated with the client.
abstract member DisposeAsync : unit -> Async<unit>

0 comments on commit df4be6f

Please sign in to comment.