Module
Erl.Cowboy.Handlers.WebSocket
- Package
- erl-cowboy
- Repository
- purerl/purescript-erl-cowboy
Types and helpers for a cowboy_websocket Websockets callback module
See Erl.Cowboy.Handlers.
Example:
_behaviour :: CowboyWebsocketBehaviour
_behaviour = cowboyWebsocketBehaviour { init, websocket_handle, websocket_info }
data Config
data HandlerState
init :: InitHandler Config HandlerState
init = ...
websocket_handle :: FrameHandler HandlerState
websocket_handle = ...
websocket_info :: InfoHandler HandlerState
websocket_info = ...
#InitResult Source
data InitResult :: Type -> Type#InitHandler Source
type InitHandler c s = EffectFn2 Req c (InitResult s)Init handler to upgrade to cowboy_websocket -- init()
#initResult Source
initResult :: forall a. a -> Req -> InitResult a#FrameHandler Source
type FrameHandler s = EffectFn2 InFrame s (CallResult s)Main frame handler - websocket_handle()
#decodeInFrame Source
decodeInFrame :: InFrame -> Frame#CallResult Source
data CallResult :: Type -> Type#okResult Source
okResult :: forall s. s -> CallResult s#hibernateResult Source
hibernateResult :: forall s. s -> CallResult s#replyResult Source
replyResult :: forall s. s -> List OutFrame -> CallResult s#replyAndHibernateResult Source
replyAndHibernateResult :: forall s. s -> List OutFrame -> CallResult s#stopResult Source
stopResult :: forall s. s -> CallResult s#WSInitHandler Source
type WSInitHandler s = EffectFn1 s (CallResult s)Optional WS init handler (post-upgrade run in websocket process - websocket_init())
#InfoHandler Source
type InfoHandler a s = EffectFn2 a s (CallResult s)Handler for erlang info messages - websocket_info()
#TerminateReason Source
data TerminateReasonConstructors
#RawTerminateReason Source
data RawTerminateReason :: TypeThis is different from other callback modules terminate reasons
#PartialReq Source
data PartialReq :: TypeCowboy does not provide the full Req object to terminate, so currently completely opaque
#CowboyWebsocketBehaviour Source
type CowboyWebsocketBehaviour = Behaviour "cowboy_websocket"#cowboyWebsocketBehaviour Source
cowboyWebsocketBehaviour :: forall a i s. { init :: InitHandler a s, websocket_handle :: FrameHandler s, websocket_info :: InfoHandler i s } -> CowboyWebsocketBehaviour