hspread-0.3: A client library for the spread toolkitContentsIndex
Spread.Client
Synopsis
data OutMsg = Outgoing {
outOrdering :: !OrderingType
outDiscard :: !Bool
outData :: !ByteString
outGroups :: ![Group]
outMsgType :: !Word16
}
data InMsg = Incoming {
inOrdering :: !OrderingType
inSender :: !PrivateGroup
inData :: !ByteString
inGroups :: ![Group]
inMsgType :: !Word16
inEndianMismatch :: !Bool
}
data Message
= Regular !InMsg
| Membership !MembershipMsg
| Rejected !RejectedMsg
data Group
type PrivateGroup = Group
data PrivateName
data GroupId
data OrderingType
= Unreliable
| Reliable
| Fifo
| Causal
| Agreed
| Safe
data Cause
= Join {
joining :: !PrivateGroup
}
| Leave {
leaving :: !PrivateGroup
}
| Disconnect {
disconnecting :: !PrivateGroup
}
| Network {
sets :: ![[PrivateGroup]]
localSet :: ![PrivateGroup]
}
groupName :: Group -> ByteString
privateName :: PrivateName -> ByteString
data GroupMsg
= Joining {
grp :: !Group
}
| Leaving {
grp :: !Group
}
data MembershipMsg
= Transient {
changingGroup :: !Group
}
| Reg {
changingGroup :: !Group
index :: !Int
numMembers :: !Int
members :: ![PrivateGroup]
groupId :: !GroupId
cause :: !Cause
}
| SelfLeave {
changingGroup :: !Group
}
mkGroup :: ByteString -> Maybe Group
putPadded :: Int -> ByteString -> PutM ()
data KillMsg = Kill PrivateGroup
data RejectedMsg
= WasGroup !GroupMsg
| WasOut !OutMsg
data Connection
privateGroup :: Connection -> PrivateGroup
data Conf = Conf {
address :: !(Maybe HostName)
port :: !(Maybe PortNumber)
desiredName :: !PrivateName
priority :: !Bool
groupMembership :: !Bool
authMethods :: ![AuthMethod]
}
defaultConf :: Conf
data AuthName
mkAuthName :: ByteString -> AuthName
authname :: AuthName -> ByteString
type AuthMethod = (AuthName, Handle -> IO Bool)
connect :: Conf -> IO (Chan R Message, Connection)
disconnect :: Connection -> IO ()
startReceive :: Connection -> IO Bool
stopReceive :: Connection -> IO Bool
getDupedChan :: Connection -> IO (Chan R Message)
join :: Group -> Connection -> IO ()
leave :: Group -> Connection -> IO ()
send :: OutMsg -> Connection -> IO ()
Documentation
data OutMsg
Message to be sent.
Constructors
Outgoing
outOrdering :: !OrderingType
outDiscard :: !BoolIf True you won't get a copy of this message back from the server.
outData :: !ByteStringMessage body.
outGroups :: ![Group]Recipients of the message
outMsgType :: !Word16To be used by the application to identify the kind of message.
show/hide Instances
data InMsg
Message received.
Constructors
Incoming
inOrdering :: !OrderingType
inSender :: !PrivateGroup
inData :: !ByteString
inGroups :: ![Group]
inMsgType :: !Word16
inEndianMismatch :: !BoolTrue if the message has been sent with a different endian order.
show/hide Instances
data Message
Union Type of messages that can be received from the server.
Constructors
Regular !InMsg
Membership !MembershipMsg
Rejected !RejectedMsg
show/hide Instances
data Group
A Group is a collection of clients identified by a name.
show/hide Instances
type PrivateGroup = Group
A PrivateGroup identifies a connection.
data PrivateName
Initial part of a PrivateGroup name that is chosen by the client when connecting.
show/hide Instances
data GroupId
Identifier for a membership message.
show/hide Instances
data OrderingType
Represents the orderings as specified by the Spread toolkit.
Constructors
Unreliable
Reliable
Fifo
Causal
Agreed
Safe
show/hide Instances
data Cause
What caused a membership message.
Constructors
Join
joining :: !PrivateGroup
Leave
leaving :: !PrivateGroup
Disconnect
disconnecting :: !PrivateGroup
Network
sets :: ![[PrivateGroup]]
localSet :: ![PrivateGroup]
show/hide Instances
groupName :: Group -> ByteString
privateName :: PrivateName -> ByteString
data GroupMsg
Messages used to join or leave a group.
Constructors
Joining
grp :: !Group
Leaving
grp :: !Group
show/hide Instances
data MembershipMsg
Message regarding changes in group membership.
Constructors
Transient
changingGroup :: !Group
Reg
changingGroup :: !Group
index :: !Int
numMembers :: !Int
members :: ![PrivateGroup]
groupId :: !GroupId
cause :: !Cause
SelfLeave
changingGroup :: !Group
show/hide Instances
mkGroup :: ByteString -> Maybe Group
putPadded :: Int -> ByteString -> PutM ()
data KillMsg
Constructors
Kill PrivateGroup
show/hide Instances
Sendable KillMsg
data RejectedMsg
Constructors
WasGroup !GroupMsg
WasOut !OutMsg
show/hide Instances
data Connection
Abstract type representing a connection with a spread server.
privateGroup :: Connection -> PrivateGroup
private name of this connection, useful for p2p messages.
data Conf
Configuration passed to connect
Constructors
Conf
address :: !(Maybe HostName)Server address, using localhost if Nothing.
port :: !(Maybe PortNumber)Server port, uses the default spread port if Nothing.
desiredName :: !PrivateNameIt will become part of the PrivateGroup of the Connection
priority :: !BoolIs this a priority connection?
groupMembership :: !BoolShould it receive Membership messages?
authMethods :: ![AuthMethod]Authentication methods to use when connecting.
defaultConf :: Conf
defaulConf = Conf Nothing Nothing (mkPrivateName (B.pack "user")) False True []
data AuthName
Name of an authentication method.
show/hide Instances
mkAuthName :: ByteString -> AuthName
The ByteString will be truncated to the maximum allowed size.
authname :: AuthName -> ByteString
type AuthMethod = (AuthName, Handle -> IO Bool)
The action should return True if the authentication succeded.
connect :: Conf -> IO (Chan R Message, Connection)
Connects to the specified server, will use a "NULL" authentication method if the authMethods list is empty. A spread server will refuse the connection if another with the same PrivateName is still active.
disconnect :: Connection -> IO ()
Sends a disconnection message to the server, which will close the connection.
startReceive :: Connection -> IO Bool
Start fetching messages from the network, returns True if it was stopped.
stopReceive :: Connection -> IO Bool
Stop fetching messages from the network (at most one more message can be read) , returns True if it was started.
getDupedChan :: Connection -> IO (Chan R Message)
Messages received from now on will be available on the returned Chan
join :: Group -> Connection -> IO ()
Joins a group, the server will send a Reg.
leave :: Group -> Connection -> IO ()
Leaves a group, the server will send a SelfLeave.
send :: OutMsg -> Connection -> IO ()
Send a regular message.
Produced by Haddock version 0.8