| Copyright | (c) Lars Petersen 2016 |
|---|---|
| License | MIT |
| Maintainer | info@lars-petersen.net |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Network.MQTT.Broker.Session
Description
- publish :: Session auth -> Message -> IO ()
- subscribe :: Session auth -> PacketIdentifier -> [(Filter, QoS)] -> IO ()
- unsubscribe :: Session auth -> PacketIdentifier -> [Filter] -> IO ()
- disconnect :: Session auth -> IO ()
- terminate :: Session auth -> IO ()
- getSubscriptions :: Session auth -> IO (Trie QoS)
- getConnection :: Session auth -> IO (Maybe Connection)
- getPrincipal :: Session auth -> IO Principal
- getFreePacketIdentifiers :: Session auth -> IO (Seq PacketIdentifier)
- reset :: Session auth -> IO ()
- notePending :: Session auth -> IO ()
- waitPending :: Session auth -> IO ()
- publishMessage :: Session auth -> Message -> IO ()
- publishMessages :: Foldable t => Session auth -> t Message -> IO ()
- enqueuePingResponse :: Session auth -> IO ()
- enqueueMessage :: Session auth -> Message -> IO ()
- enqueueSubscribeAcknowledged :: Session auth -> PacketIdentifier -> [Maybe QoS] -> IO ()
- enqueueUnsubscribeAcknowledged :: Session auth -> PacketIdentifier -> IO ()
- dequeue :: Session auth -> IO (Seq ServerPacket)
- processPublish :: Session auth -> PacketIdentifier -> Duplicate -> Message -> IO ()
- processPublishRelease :: Session auth -> PacketIdentifier -> IO ()
- processPublishReceived :: Session auth -> PacketIdentifier -> IO ()
- processPublishComplete :: Session auth -> PacketIdentifier -> IO ()
- processPublishAcknowledged :: Session auth -> PacketIdentifier -> IO ()
- data Session auth = Session {
- sessionBroker :: !(Broker auth)
- sessionIdentifier :: !SessionIdentifier
- sessionClientIdentifier :: !ClientIdentifier
- sessionPrincipalIdentifier :: !PrincipalIdentifier
- sessionCreatedAt :: !Int64
- sessionConnection :: !(MVar Connection)
- sessionPrincipal :: !(MVar Principal)
- sessionSemaphore :: !PrioritySemaphore
- sessionSubscriptions :: !(MVar (Trie QoS))
- sessionQueue :: !(MVar ServerQueue)
- sessionQueuePending :: !(MVar ())
- sessionStatistics :: !Statistics
- newtype SessionIdentifier = SessionIdentifier Int
- data Connection = Connection {}
Documentation
unsubscribe :: Session auth -> PacketIdentifier -> [Filter] -> IO () Source #
disconnect :: Session auth -> IO () Source #
Disconnect a session.
terminate :: Session auth -> IO () Source #
Terminate a session.
- An eventually connected client gets disconnected.
- The session subscriptions are removed from the subscription tree which means that it will receive no more messages.
- The session will be unlinked from the broker which means that clients cannot resume it anymore under this client identifier.
getConnection :: Session auth -> IO (Maybe Connection) Source #
getFreePacketIdentifiers :: Session auth -> IO (Seq PacketIdentifier) Source #
reset :: Session auth -> IO () Source #
Reset the session state after a reconnect.
- All output buffers will be cleared.
- Output buffers will be filled with retransmissions.
notePending :: Session auth -> IO () Source #
waitPending :: Session auth -> IO () Source #
enqueuePingResponse :: Session auth -> IO () Source #
Enqueue a PINGRESP to be sent as soon as the output thread is available.
The PINGRESP will be inserted with highest priority in front of all other enqueued messages.
enqueueMessage :: Session auth -> Message -> IO () Source #
This enqueues a message for transmission to the client.
- This operations eventually terminates the session on queue overflow. The caller will not notice this and the operation will not throw an exception.
enqueueSubscribeAcknowledged :: Session auth -> PacketIdentifier -> [Maybe QoS] -> IO () Source #
enqueueUnsubscribeAcknowledged :: Session auth -> PacketIdentifier -> IO () Source #
dequeue :: Session auth -> IO (Seq ServerPacket) Source #
Blocks until messages are available and prefers non-qos0 messages over qos0 messages.
processPublish :: Session auth -> PacketIdentifier -> Duplicate -> Message -> IO () Source #
Process a PUB message received from the peer.
Different handling depending on message qos.
processPublishRelease :: Session auth -> PacketIdentifier -> IO () Source #
Release a QoS2 message.
This shall be called when PUBREL has been received from the peer.
It enqueues an outgoing PUBCOMP.
The message is only released if the handler returned without exception.
The handler is only executed if there still is a message (it is a valid scenario
that it might already have been released).
processPublishReceived :: Session auth -> PacketIdentifier -> IO () Source #
Note that a QoS2 message has been received by the peer.
This shall be called when a PUBREC has been received from the peer.
This is the completion of the second step in a 4-way handshake.
The state changes from _not received_ to _not completed_.
We will send a PUBREL to the client and expect a PUBCOMP in return.
processPublishComplete :: Session auth -> PacketIdentifier -> IO () Source #
Complete the transmission of a QoS2 message.
This shall be called when a PUBCOMP has been received from the peer
to finally free the packet identifier.
processPublishAcknowledged :: Session auth -> PacketIdentifier -> IO () Source #
Note that a QoS1 message has been received by the peer.
This shall be called when a PUBACK has been received by the peer.
We release the message from our buffer and the transaction is then complete.
Constructors
| Session | |
Fields
| |
newtype SessionIdentifier Source #
Constructors
| SessionIdentifier Int |