magic-wormhole-0.3.4: Interact with Magic Wormhole

Safe HaskellNone
LanguageHaskell2010

MagicWormhole.Internal.Messages

Description

Messages sent to and from the Rendezvous server.

Synopsis

Documentation

data ClientMessage Source #

A message sent from a rendezvous client to the server.

Constructors

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 Claim) earlier in this connection.

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 Pong. Used for testing.

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)

Constructors

Welcome WelcomeMessage

Sent by the server on initial connection.

Nameplates

Sent in response to "list"

Fields

Allocated

Sent in response to "allocate"

Fields

Claimed

Sent in response to "claim"

Fields

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.

Fields

newtype AppID Source #

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.

Constructors

AppID Text 
Instances
Eq AppID Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

(==) :: AppID -> AppID -> Bool #

(/=) :: AppID -> AppID -> Bool #

Show AppID Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

showsPrec :: Int -> AppID -> ShowS #

show :: AppID -> String #

showList :: [AppID] -> ShowS #

ToJSON AppID Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

FromJSON AppID Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

data MailboxMessage Source #

A message sent to a mailbox.

Constructors

MailboxMessage 

Fields

  • side :: Side

    Which side sent the message. Might be our side.

  • phase :: Phase

    Which phase of the client protocol we are in.

  • messageID :: Maybe MessageID

    An identifier for the message. Unused.

    According to the protocol docs, this should always be set, but the Python server will happily mirror an absent id field as null.

  • body :: Body

    The body of the message. To be interpreted by the client protocol.

data WelcomeMessage Source #

Message received on initial connection to the server.

Constructors

WelcomeMessage 

Fields

newtype MessageID Source #

Identifier sent with every client message that is included in the matching server responses.

Constructors

MessageID Int16 

newtype Side Source #

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.

Constructors

Side Text 
Instances
Eq Side Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

(==) :: Side -> Side -> Bool #

(/=) :: Side -> Side -> Bool #

Show Side Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

showsPrec :: Int -> Side -> ShowS #

show :: Side -> String #

showList :: [Side] -> ShowS #

ToJSON Side Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

FromJSON Side Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

generateSide :: MonadRandom randomly => randomly Side Source #

Generate a random Side

data Phase Source #

A phase in the peer-to-peer (aka "client") protocol.

Phases proceed in strict order: PakePhase, VersionPhase, then many ApplicationPhase.

Constructors

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 # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

(==) :: Phase -> Phase -> Bool #

(/=) :: Phase -> Phase -> Bool #

Show Phase Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

showsPrec :: Int -> Phase -> ShowS #

show :: Phase -> String #

showList :: [Phase] -> ShowS #

ToJSON Phase Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

FromJSON Phase Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

phaseName :: Phase -> Text Source #

Get the name of the phase. Used to derive message keys.

newtype Body Source #

The body of a Magic Wormhole message.

This can be any arbitrary bytestring that is sent to or received from a wormhole peer.

Constructors

Body ByteString 
Instances
Eq Body Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

(==) :: Body -> Body -> Bool #

(/=) :: Body -> Body -> Bool #

Show Body Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

showsPrec :: Int -> Body -> ShowS #

show :: Body -> String #

showList :: [Body] -> ShowS #

ToJSON Body Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

FromJSON Body Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

newtype Nameplate Source #

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.

Constructors

Nameplate Text 

newtype Mailbox Source #

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.

Constructors

Mailbox Text 

data Mood Source #

How the client feels. Reported by the client to the server at the end of a wormhole session.

Constructors

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 # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

(==) :: Mood -> Mood -> Bool #

(/=) :: Mood -> Mood -> Bool #

Show Mood Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

Methods

showsPrec :: Int -> Mood -> ShowS #

show :: Mood -> String #

showList :: [Mood] -> ShowS #

ToJSON Mood Source # 
Instance details

Defined in MagicWormhole.Internal.Messages

FromJSON Mood Source # 
Instance details

Defined in MagicWormhole.Internal.Messages