hspread-0.3: A client library for the spread toolkit

Spread.Client

Synopsis

Documentation

data OutMsg Source

Message to be sent.

Constructors

Outgoing 

Fields

outOrdering :: !OrderingType
 
outDiscard :: !Bool

If True you won't get a copy of this message back from the server.

outData :: !ByteString

Message body.

outGroups :: ![Group]

Recipients of the message

outMsgType :: !Word16

To be used by the application to identify the kind of message.

Instances

Show OutMsg 
Sendable OutMsg 

data InMsg Source

Message received.

Constructors

Incoming 

Fields

inOrdering :: !OrderingType
 
inSender :: !PrivateGroup
 
inData :: !ByteString
 
inGroups :: ![Group]
 
inMsgType :: !Word16
 
inEndianMismatch :: !Bool

True if the message has been sent with a different endian order.

Instances

data Message Source

Union Type of messages that can be received from the server.

Instances

data Group Source

A Group is a collection of clients identified by a name.

Instances

type PrivateGroup = GroupSource

A PrivateGroup identifies a connection.

data PrivateName Source

Initial part of a PrivateGroup name that is chosen by the client when connecting.

data GroupId Source

Identifier for a membership message.

Instances

data OrderingType Source

Represents the orderings as specified by the Spread toolkit.

data Cause Source

What caused a membership message.

Constructors

Join 

Fields

joining :: !PrivateGroup
 
Leave 

Fields

leaving :: !PrivateGroup
 
Disconnect 
Network 

Fields

sets :: ![[PrivateGroup]]
 
localSet :: ![PrivateGroup]
 

Instances

data GroupMsg Source

Messages used to join or leave a group.

Constructors

Joining 

Fields

grp :: !Group
 
Leaving 

Fields

grp :: !Group
 

Instances

Show GroupMsg 
Sendable GroupMsg 

data MembershipMsg Source

Message regarding changes in group membership.

Constructors

Transient 

Fields

changingGroup :: !Group
 
Reg 
SelfLeave 

Fields

changingGroup :: !Group
 

Instances

multicast_internal :: Sendable a => PrivateGroup -> a -> Handle -> IO BoolSource

data KillMsg Source

Constructors

Kill PrivateGroup 

Instances

Sendable KillMsg 

data Connection Source

Abstract type representing a connection with a spread server.

privateGroup :: Connection -> PrivateGroupSource

private name of this connection, useful for p2p messages.

data Conf Source

Configuration passed to connect

Constructors

Conf 

Fields

address :: !(Maybe HostName)

Server address, using localhost if Nothing.

port :: !(Maybe PortNumber)

Server port, uses the default spread port if Nothing.

desiredName :: !PrivateName

It will become part of the PrivateGroup of the Connection

priority :: !Bool

Is this a priority connection?

groupMembership :: !Bool

Should it receive Membership messages?

authMethods :: ![AuthMethod]

Authentication methods to use when connecting.

defaultConf :: ConfSource

defaulConf = Conf Nothing Nothing (mkPrivateName (B.pack "user")) False True []

data AuthName Source

Name of an authentication method.

Instances

mkAuthName :: ByteString -> AuthNameSource

The ByteString will be truncated to the maximum allowed size.

type AuthMethod = (AuthName, Handle -> IO Bool)Source

The action should return True if the authentication succeded.

connect :: Conf -> IO (Chan R Message, Connection)Source

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 ()Source

Sends a disconnection message to the server, which will close the connection.

startReceive :: Connection -> IO BoolSource

Start fetching messages from the network, returns True if it was stopped.

stopReceive :: Connection -> IO BoolSource

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)Source

Messages received from now on will be available on the returned Chan

join :: Group -> Connection -> IO ()Source

Joins a group, the server will send a Reg.

leave :: Group -> Connection -> IO ()Source

Leaves a group, the server will send a SelfLeave.

send :: OutMsg -> Connection -> IO ()Source

Send a regular message.