gore-and-ash-network-1.4.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 :: LoggingMonad m => Maybe SockAddr -> Word -> Word -> Word32 -> Word32 -> m () Source #

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 :: LoggingMonad m => SockAddr -> Word -> Word32 -> m (Maybe ()) Source #

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

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