network-messagepack-rpc-websocket-0.1.1.1: WebSocket backend for MessagePack RPC

Safe HaskellNone
LanguageHaskell2010

Network.MessagePack.RPC.Client.WebSocket

Contents

Description

MessagePack RPC Client based on WebSocket.

Synopsis

Config

data Config #

Configuration for MessagePack RPC.

Constructors

Config 

Fields

type NotificationHandler = Client -> MethodName -> [Object] -> IO () #

Notification handler. The 3rd argument is response objects.

type RequestHandler = Client -> MessageId -> MethodName -> [Object] -> IO () #

Notification handler. The 2nd argument is message id to be used for replying. The 3rd argument is response objects.

type Logger = String -> IO () #

Logger type. Should print out the message passed as a first argument somewhere.

type Formatter = Message -> String #

Convert Message into a String to print out by Logger

defaultConfig :: Config #

The default configuration. formatter is show. Others do nothing.

Backend

data Backend #

Backend IO functions. Any receiving / sending actions are performed by calling these functions.

Constructors

Backend 

Fields

Client

type URL = String Source #

URL for websocket end points.

data Client #

A client data type for MessagePack RPC.

withClient Source #

Arguments

:: URL

URL

-> Config

Configuration

-> (Client -> IO a)

Action

-> IO a 

Executing the action in the 3rd argument with a Client.

shutdown :: Client -> IO () #

This function cleans up the internal states including the termination of internal threads.

Call and reply

type Result = Either Object Object #

Result type of a RPC call. Described as "error" and "result" of "Response Message" in the spec of MessagePack RPC.

call :: Client -> MethodName -> [Object] -> IO Result #

Calling RPC.

reply :: Client -> MessageId -> Result -> IO () #

Replying RPC. This should be used in RequestHandler.