Copyright | (c) James Sully 2020-2021 |
---|---|
License | BSD 3-Clause |
Maintainer | sullyj3@gmail.com |
Stability | experimental |
Portability | untested |
Safe Haskell | None |
Language | Haskell2010 |
Provides methods of connecting to a Buttplug Server
Synopsis
- class Connector c where
- type Connection c = conn | conn -> c
- runClient :: c -> (Connection c -> IO a) -> IO a
- sendMessages :: Connection c -> [Message] -> IO ()
- receiveMsgs :: Connection c -> IO [Message]
- sendMessage :: forall c. Connector c => Connection c -> Message -> IO ()
- data WebSocketConnector
- data ConnectorException
- handleWSConnFailed :: HandshakeException -> IO a
- handleSockConnFailed :: IOError -> IO a
- handleWSConnException :: ConnectionException -> IO a
Documentation
class Connector c where Source #
Abstracts over methods of connecting to a buttplug server. The connector contains all the information necessary for establishing a connection.
type Connection c = conn | conn -> c Source #
A Connector determines a unique connection type that is used for communication.
runClient :: c -> (Connection c -> IO a) -> IO a Source #
Main entry point for communicating with the Buttplug server. Establish a connection to the server and pass the connection handle to the continuation.
sendMessages :: Connection c -> [Message] -> IO () Source #
Send Message
s to the server. In the Buttplug protocol, all messages
are wrapped in a JSON array (here a Haskell list) to facilitate sending
multiple messages simultaneously. Use sendMessage
to send a single
message.
receiveMsgs :: Connection c -> IO [Message] Source #
receive Message
s from the server
Instances
Connector WebSocketConnector Source # | |
Defined in Buttplug.Core.Connector type Connection WebSocketConnector = (conn :: Type) Source # runClient :: WebSocketConnector -> (Connection WebSocketConnector -> IO a) -> IO a Source # sendMessages :: Connection WebSocketConnector -> [Message] -> IO () Source # receiveMsgs :: Connection WebSocketConnector -> IO [Message] Source # |
sendMessage :: forall c. Connector c => Connection c -> Message -> IO () Source #
Send the server a single Message
data WebSocketConnector Source #
Connect to the buttplug server using websockets
InsecureWebSocketConnector | |
SecureWebSocketConnector | |
|
Instances
Connector WebSocketConnector Source # | |
Defined in Buttplug.Core.Connector type Connection WebSocketConnector = (conn :: Type) Source # runClient :: WebSocketConnector -> (Connection WebSocketConnector -> IO a) -> IO a Source # sendMessages :: Connection WebSocketConnector -> [Message] -> IO () Source # receiveMsgs :: Connection WebSocketConnector -> IO [Message] Source # | |
type Connection WebSocketConnector Source # | |
Defined in Buttplug.Core.Connector |
data ConnectorException Source #
An exception type abstracting over the exceptions that might arise in the
course of communication with the buttplug server. Connector
instances in
general should throw these rather than Exceptions specific to the connection
type.
ConnectionFailed String | |
UnexpectedConnectionClosed | |
ConnectionClosedNormally | |
ReceivedInvalidMessage ByteString | |
OtherConnectorError String |
Instances
Show ConnectorException Source # | |
Defined in Buttplug.Core.Connector showsPrec :: Int -> ConnectorException -> ShowS # show :: ConnectorException -> String # showList :: [ConnectorException] -> ShowS # | |
Exception ConnectorException Source # | |
Defined in Buttplug.Core.Connector |
handleWSConnFailed :: HandshakeException -> IO a Source #
Convert HandshakeException
into ConnectionFailed
handleSockConnFailed :: IOError -> IO a Source #
Convert socket connection issues into ConnectionFailed
handleWSConnException :: ConnectionException -> IO a Source #
Convert websocket specific connection exceptions into ConnectorException