Safe Haskell | None |
---|---|
Language | Haskell2010 |
Messages sent to and from the Rendezvous server.
Synopsis
- data ClientMessage
- data ServerMessage
- = Welcome WelcomeMessage
- | Nameplates {
- nameplates :: [Nameplate]
- | Allocated { }
- | Claimed { }
- | Released
- | Message MailboxMessage
- | Closed
- | Ack
- | Pong Int
- | Error {
- errorMessage :: Text
- original :: ClientMessage
- newtype AppID = AppID Text
- data MailboxMessage = MailboxMessage {}
- data WelcomeMessage = WelcomeMessage {
- motd :: Maybe Text
- welcomeErrorMessage :: Maybe Text
- newtype MessageID = MessageID Int16
- newtype Side = Side Text
- generateSide :: MonadRandom randomly => randomly Side
- data Phase
- = PakePhase
- | VersionPhase
- | ApplicationPhase Int
- phaseName :: Phase -> Text
- newtype Body = Body ByteString
- newtype Nameplate = Nameplate Text
- newtype Mailbox = Mailbox Text
- data Mood
Documentation
data ClientMessage Source #
A message sent from a rendezvous client to the server.
Bind AppID Side | Set the application ID and the "side" for the duration of the connection. |
List | Get a list of all allocated nameplates. |
Allocate | Ask the server to allocate a nameplate |
Claim Nameplate | Claim a nameplate. |
Release (Maybe Nameplate) | Release a claimed nameplate. If no nameplate is provided, the server will attempt to release the
nameplate claimed (via |
Open Mailbox | Open a mailbox. |
Add Phase Body | Send a message to an open mailbox. The message will be delivered to all connected clients that also have that mailbox open, including this one. |
Close (Maybe Mailbox) (Maybe Mood) | Close a mailbox. Since only one mailbox can be open at a time, if mailbox isn't specified, then close the open mailbox. |
Ping Int | Internal "ping". Response is |
Instances
Eq ClientMessage Source # | |
Defined in MagicWormhole.Internal.Messages (==) :: ClientMessage -> ClientMessage -> Bool (/=) :: ClientMessage -> ClientMessage -> Bool | |
Show ClientMessage Source # | |
Defined in MagicWormhole.Internal.Messages showsPrec :: Int -> ClientMessage -> ShowS show :: ClientMessage -> String showList :: [ClientMessage] -> ShowS | |
FromJSON ClientMessage Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser ClientMessage parseJSONList :: Value -> Parser [ClientMessage] | |
ToJSON ClientMessage Source # | |
Defined in MagicWormhole.Internal.Messages toJSON :: ClientMessage -> Value toEncoding :: ClientMessage -> Encoding toJSONList :: [ClientMessage] -> Value toEncodingList :: [ClientMessage] -> Encoding |
data ServerMessage Source #
A message received from the server.
Some open questions:
* general message stuff--how are we going to model this?
* outgoing messages include a randomly generated id
field, which is
returned by the server
* messages from the server include server_tx
, a float timestamp recording
when the server received the message
* messages from the server that are direct responses include a server_rx
timestamp--unclear what this means?
* do we want a separate Haskell type for each message type? e.g. PingMessage
* if we do that, how do associate request/response pairs? e.g. PingMessage &
PongMessage?
* do we want to (can we even?) structurally distinguish between messages that
make sense outside the scope of a binding (e.g. ping) and messages that only
make sense after a bind (e.g. allocate)
Welcome WelcomeMessage | Sent by the server on initial connection. |
Nameplates | Sent in response to "list" |
| |
Allocated | Sent in response to "allocate" |
Claimed | Sent in response to "claim" |
Released | Sent in response to "release" |
Message MailboxMessage | A message sent to the mailbox |
Closed | Sent in response to "close" |
Ack | Sent immediately after every message. Unused. |
Pong Int | Sent in response to "pong" |
Error | Sent by the server when it receives something from the client that it does not understand. |
|
Instances
Eq ServerMessage Source # | |
Defined in MagicWormhole.Internal.Messages (==) :: ServerMessage -> ServerMessage -> Bool (/=) :: ServerMessage -> ServerMessage -> Bool | |
Show ServerMessage Source # | |
Defined in MagicWormhole.Internal.Messages showsPrec :: Int -> ServerMessage -> ShowS show :: ServerMessage -> String showList :: [ServerMessage] -> ShowS | |
FromJSON ServerMessage Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser ServerMessage parseJSONList :: Value -> Parser [ServerMessage] | |
ToJSON ServerMessage Source # | |
Defined in MagicWormhole.Internal.Messages toJSON :: ServerMessage -> Value toEncoding :: ServerMessage -> Encoding toJSONList :: [ServerMessage] -> Value toEncodingList :: [ServerMessage] -> Encoding |
Short string to identify the application. Clients must use the same application ID if they wish to communicate with each other.
Recommendation is to use "$DNSNAME/$APPNAME", e.g.
the Python wormhole
command-line tool uses
lothar.com/wormhole/text-or-file-xfer
.
AppID Text |
Instances
Eq AppID Source # | |
Show AppID Source # | |
FromJSON AppID Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser AppID parseJSONList :: Value -> Parser [AppID] | |
ToJSON AppID Source # | |
Defined in MagicWormhole.Internal.Messages |
data MailboxMessage Source #
A message sent to a mailbox.
MailboxMessage | |
|
Instances
Eq MailboxMessage Source # | |
Defined in MagicWormhole.Internal.Messages (==) :: MailboxMessage -> MailboxMessage -> Bool (/=) :: MailboxMessage -> MailboxMessage -> Bool | |
Show MailboxMessage Source # | |
Defined in MagicWormhole.Internal.Messages showsPrec :: Int -> MailboxMessage -> ShowS show :: MailboxMessage -> String showList :: [MailboxMessage] -> ShowS |
data WelcomeMessage Source #
Message received on initial connection to the server.
WelcomeMessage | |
|
Instances
Eq WelcomeMessage Source # | |
Defined in MagicWormhole.Internal.Messages (==) :: WelcomeMessage -> WelcomeMessage -> Bool (/=) :: WelcomeMessage -> WelcomeMessage -> Bool | |
Show WelcomeMessage Source # | |
Defined in MagicWormhole.Internal.Messages showsPrec :: Int -> WelcomeMessage -> ShowS show :: WelcomeMessage -> String showList :: [WelcomeMessage] -> ShowS |
Identifier sent with every client message that is included in the matching server responses.
MessageID Int16 |
Instances
Eq MessageID Source # | |
Show MessageID Source # | |
Hashable MessageID Source # | |
Defined in MagicWormhole.Internal.Messages hashWithSalt :: Int -> MessageID -> Int | |
FromJSON MessageID Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser MessageID parseJSONList :: Value -> Parser [MessageID] | |
ToJSON MessageID Source # | |
Defined in MagicWormhole.Internal.Messages toEncoding :: MessageID -> Encoding toJSONList :: [MessageID] -> Value toEncodingList :: [MessageID] -> Encoding |
Short string used to differentiate between echoes of our own messages and real messages from other clients.
TODO: This needs to be cleanly encoded to ASCII, so update the type or provide a smart constructor.
Side Text |
Instances
Eq Side Source # | |
Show Side Source # | |
FromJSON Side Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser Side parseJSONList :: Value -> Parser [Side] | |
ToJSON Side Source # | |
Defined in MagicWormhole.Internal.Messages |
generateSide :: MonadRandom randomly => randomly Side Source #
Generate a random Side
A phase in the peer-to-peer (aka "client") protocol.
Phases proceed in strict order: PakePhase
, VersionPhase
, then
many ApplicationPhase
.
PakePhase | Sent immediately on opening the mailbox. |
VersionPhase | Used to negotiate capabilities. |
ApplicationPhase Int | Reserved for application data. Messages with these phases will be delivered in numeric order. |
Instances
Eq Phase Source # | |
Show Phase Source # | |
FromJSON Phase Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser Phase parseJSONList :: Value -> Parser [Phase] | |
ToJSON Phase Source # | |
Defined in MagicWormhole.Internal.Messages |
The body of a Magic Wormhole message.
This can be any arbitrary bytestring that is sent to or received from a wormhole peer.
Body ByteString |
Instances
Eq Body Source # | |
Show Body Source # | |
FromJSON Body Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser Body parseJSONList :: Value -> Parser [Body] | |
ToJSON Body Source # | |
Defined in MagicWormhole.Internal.Messages |
Identifier for a "nameplate".
A nameplate is a very short string that identifies one peer to another. Its
purpose is to allow peers to find each other without having to communicate
the Mailbox
identifier, which is generally too lengthy and cumbersome to
be easily shared between humans.
Typically, one peer will allocate a nameplate and then communicate it out-of-band to the other peer.
Nameplate Text |
Instances
Eq Nameplate Source # | |
Show Nameplate Source # | |
FromJSON Nameplate Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser Nameplate parseJSONList :: Value -> Parser [Nameplate] | |
ToJSON Nameplate Source # | |
Defined in MagicWormhole.Internal.Messages toEncoding :: Nameplate -> Encoding toJSONList :: [Nameplate] -> Value toEncodingList :: [Nameplate] -> Encoding |
Identifier for a mailbox.
A mailbox is a shared access point between Magic Wormhole peers within the
same application (specified by AppID
). To get a mailbox, you must first
acquire a Nameplate
and then claim that nameplate for your side with
claim
.
A mailbox ID is defined in the spec as a "large random string", but in practice is a 13 character, lower-case, alpha-numeric string.
Mailbox Text |
Instances
Eq Mailbox Source # | |
Show Mailbox Source # | |
FromJSON Mailbox Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser Mailbox parseJSONList :: Value -> Parser [Mailbox] | |
ToJSON Mailbox Source # | |
Defined in MagicWormhole.Internal.Messages toEncoding :: Mailbox -> Encoding toJSONList :: [Mailbox] -> Value toEncodingList :: [Mailbox] -> Encoding |
How the client feels. Reported by the client to the server at the end of a wormhole session.
Happy | The client had a great session with its peer. |
Lonely | The client never saw its peer. |
Scary | The client saw a peer it could not trust. |
Errory | The client encountered some problem. |
Instances
Eq Mood Source # | |
Show Mood Source # | |
FromJSON Mood Source # | |
Defined in MagicWormhole.Internal.Messages parseJSON :: Value -> Parser Mood parseJSONList :: Value -> Parser [Mood] | |
ToJSON Mood Source # | |
Defined in MagicWormhole.Internal.Messages |