gore-and-ash-network-1.2.0.0: Core module for Gore&Ash engine with low level network API

Copyright(c) Anton Gushcha, 2015-2016
LicenseBSD3
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Game.GoreAndAsh.Network.API

Contents

Description

The module contains monadic and arrow API of network core module.

Synopsis

Documentation

class (MonadIO m, MonadCatch m) => NetworkMonad m where Source

Low-level monadic API of the core module

Methods

networkBind Source

Arguments

:: LoggingMonad m 
=> Maybe SockAddr

Address to listen, Nothing is client

-> Word

Maximum count of connections

-> Word

Number of channels to open

-> Word32

Incoming max bandwidth

-> Word32

Outcoming max bandwidth

-> m () 

Start listening for messages, should be called once

peersConnectedM :: m (Seq Peer) Source

Returns peers that were connected during last frame

peersDisconnectedM :: m (Seq Peer) Source

Returns peers that were disconnected during last frame

networkConnect Source

Arguments

:: LoggingMonad m 
=> SockAddr

Address of host

-> Word

Count of channels to open

-> Word32

Additional data (0 default)

-> m (Maybe ()) 

Initiate connection to the remote host

peerMessagesM :: Peer -> ChannelID -> m (Seq ByteString) Source

Returns received packets for given peer and channel

peerSendM :: LoggingMonad m => Peer -> ChannelID -> Message -> m () Source

Sends a packet to given peer on given channel

networkPeersM :: m (Seq Peer) Source

Returns list of currently connected peers (servers on client side, clients on server side)

networkSetDetailedLoggingM :: Bool -> m () Source

Sets flag for detailed logging (for debug)

networkChannels :: m Word Source

Return count of allocated network channels

Instances

(MonadIO (mt m), MonadCatch (mt m), LoggingMonad m, NetworkMonad m, MonadTrans mt) => NetworkMonad (mt m) Source 
(MonadIO m, MonadCatch m) => NetworkMonad (NetworkT s m) Source 

Peer handling

peersConnected :: (LoggingMonad m, NetworkMonad m) => GameWire m a (Event (Seq Peer)) Source

Fires when one or several clients were connected

peersDisconnected :: (LoggingMonad m, NetworkMonad m) => GameWire m a (Event (Seq Peer)) Source

Fires when one of connected peers is disconnected for some reason

peerDisconnected :: (LoggingMonad m, NetworkMonad m) => Peer -> GameWire m a (Event ()) Source

Fires when statically known peer is disconnected

currentPeers :: (LoggingMonad m, NetworkMonad m) => GameWire m a (Seq Peer) Source

Returns list of current peers (clients on server, servers on client)

onPeers Source

Arguments

:: (MonadFix m, LoggingMonad m, NetworkMonad m) 
=> (Seq Peer -> GameWire m a b)

Wire that uses current peer collection

-> GameWire m a b 

Sometimes you want to listen all peers and use statefull computations at the same time.

The helper maintance internal collection of current peers and switches over it each time it changes.

Messaging support

peerMessages :: (LoggingMonad m, NetworkMonad m) => Peer -> ChannelID -> GameWire m a (Event (Seq ByteString)) Source

Returns sequence of packets that were recieved during last frame from given peer and channel id

peerSend :: (LoggingMonad m, NetworkMonad m) => Peer -> ChannelID -> GameWire m (Event Message) (Event ()) Source

Send message to given peer with given channel id

peerSendMany :: (LoggingMonad m, NetworkMonad m, Foldable t) => Peer -> ChannelID -> GameWire m (Event (t Message)) (Event ()) Source

Send several messages to given peer with given channel id