gore-and-ash-sync-1.2.0.1: Gore&Ash module for high level network synchronization

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

Game.GoreAndAsh.Sync.Message

Contents

Description

 

Synopsis

Documentation

class ActorMessage i => NetworkMessage i Source #

Extension for actor message, messages that are sent to remote host

Associated Types

type NetworkMessageType i :: * Source #

Corresponding message payload for i identifier, usually ADT

Getting messages

peerIndexedMessages Source #

Arguments

:: (ActorMonad m, SyncMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i, Serialize (NetworkMessageType i)) 
=> Peer

Which peer we are listening

-> ChannelID

Which channel we are listening

-> i

ID of actor

-> GameWire m a (Event (Seq (NetworkMessageType i)))

Messages that are addressed to the actor

Fires when network messages for specific actor has arrived Note: mid-level API is not safe to use with low-level at same time as first bytes of formed message are used for actor id. So, you need to have a special forbidden id for you custom messages.

peerProcessIndexed Source #

Arguments

:: (ActorMonad m, SyncMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i, Serialize (NetworkMessageType i)) 
=> Peer

Which peer we are listening

-> ChannelID

Which channel we are listening

-> i

ID of actor

-> (a -> NetworkMessageType i -> a)

Handler of message

-> GameWire m a a

Updates a with given handler for messages

Same as peerIndexedMessages, but transforms input state with given handler

peerProcessIndexedM Source #

Arguments

:: (ActorMonad m, SyncMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i, Serialize (NetworkMessageType i)) 
=> Peer

Which peer we are listening

-> ChannelID

Which channel we are listening

-> i

ID of actor

-> (a -> NetworkMessageType i -> GameMonadT m a)

Handler of message

-> GameWire m a a

Updates a with given handler for messages

Same as peerIndexedMessages, but transforms input state with given handler, monadic version

Sending messages

peerSendIndexedM Source #

Arguments

:: (SyncMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i, Serialize (NetworkMessageType i)) 
=> Peer

Which peer we sending to

-> ChannelID

Which channel we are sending within

-> i

ID of actor

-> MessageType

Strategy of the message (reliable, unordered etc.)

-> NetworkMessageType i

Message to send

-> m () 

Encodes a message for specific actor type and send it to remote host Note: mid-level API is not safe to use with low-level at same time as first bytes of formed message are used for actor id. So, you need to have a special forbidden id for you custom messages.

peerSendIndexed Source #

Arguments

:: (ActorMonad m, SyncMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i, Serialize (NetworkMessageType i)) 
=> Peer

Which peer we sending to

-> ChannelID

Which channel we are sending within

-> i

ID of actor

-> MessageType

Strategy of the message (reliable, unordered etc.)

-> GameWire m (Event (NetworkMessageType i)) (Event ()) 

Encodes a message for specific actor type and send it to remote host, arrow version Note: mid-level API is not safe to use with low-level at same time as first bytes of formed message are used for actor id. So, you need to have a special forbidden id for you custom messages.

peerSendIndexedDyn Source #

Arguments

:: (ActorMonad m, SyncMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i, Serialize (NetworkMessageType i)) 
=> ChannelID

Which channel we are sending within

-> MessageType

Strategy of the message (reliable, unordered etc.)

-> GameWire m (Event (Peer, i, NetworkMessageType i)) (Event ()) 

Encodes a message for specific actor type and send it to remote host, arrow version. Takes peer, id and message as arrow input.

peerSendIndexedMany Source #

Arguments

:: (ActorMonad m, SyncMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i, Serialize (NetworkMessageType i), Foldable t) 
=> Peer

Which peer we sending to

-> ChannelID

Which channel we are sending within

-> i

ID of actor

-> MessageType

Strategy of the message (reliable, unordered etc.)

-> GameWire m (Event (t (NetworkMessageType i))) (Event ()) 

Encodes a message for specific actor type and send it to remote host, arrow version Note: mid-level API is not safe to use with low-level at same time as first bytes of formed message are used for actor id. So, you need to have a special forbidden id for you custom messages.

peerSendIndexedManyDyn Source #

Arguments

:: (ActorMonad m, SyncMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i, Serialize (NetworkMessageType i), Foldable t) 
=> ChannelID

Which channel we are sending within

-> MessageType

Strategy of the message (reliable, unordered etc.)

-> GameWire m (Event (t (Peer, i, NetworkMessageType i))) (Event ()) 

Encodes a message for specific actor type and send it to remote host, arrow version. Takes peer, id and message as arrow input.

Helpers

filterMsgs Source #

Arguments

:: Monad m 
=> (a -> Bool)

Predicate to test message

-> GameWire m (Event (Seq a)) (Event (Seq a)) 

Helper to filter output of peerIndexedMessages