Photon Server API
Public Member Functions | Properties | List of all members
ExitGames.Messaging.Channels.TopicPublishChannel< T > Class Template Reference

A Concurrency.Channels.IChannel<T> wrapper that extends class TopicPublisher<T>. More...

Inheritance diagram for ExitGames.Messaging.Channels.TopicPublishChannel< T >:
ExitGames.Messaging.Channels.TopicPublisher< T > ExitGames.Concurrency.Channels.IChannel< T > ExitGames.Concurrency.Channels.IPublisher< T > ExitGames.Concurrency.Channels.ISubscriber< T > ExitGames.Concurrency.Channels.IPublisher< T > ExitGames.Messaging.Channels.TopicChannel< T >

Public Member Functions

 TopicPublishChannel (string topic, Concurrency.Channels.IChannel< T > channel, ISocketSender socketSender, IMessageSerializer< T > serializer, Guid hostId)
 Initializes a new instance of the TopicPublishChannel<T> class. More...
 
IDisposable SubscribeOnProducerThreads (IProducerThreadSubscriber< T > subscriber)
 Subscribes an IProducerThreadSubscriber<T> that is invoked when Publish is called. More...
 
void ClearSubscribers ()
 Removes all subscribers. More...
 
IDisposable Subscribe (IFiber fiber, Action< T > receive)
 Registers a callback on this channel that receives one message at a time. More...
 
IDisposable SubscribeToBatch (IFiber fiber, Action< IList< T >> receive, int intervalInMs)
 Registers a callback on this channel that receives a list of messages. More...
 
IDisposable SubscribeToKeyedBatch< TK > (IFiber fiber, Converter< T, TK > keyResolver, Action< IDictionary< TK, T >> receive, int intervalInMs)
 Registers a callback on this channel that receives a dictionary of messages. More...
 
IDisposable SubscribeToLast (IFiber fiber, Action< T > receive, int intervalInMs)
 Registers a callback on this channel that receives the last message after a timeout. More...
 
- Public Member Functions inherited from ExitGames.Messaging.Channels.TopicPublisher< T >
 TopicPublisher (string topic, Concurrency.Channels.IPublisher< T > publisher, ISocketSender socketSender, IMessageSerializer< T > serializer, Guid hostId)
 Initializes a new instance of the TopicPublisher<T> class. More...
 
void SendToSocket (T message)
 The message is serialized with the IMessageSerializer<T> and then sent as TopicMessage to the ISocketSender. More...
 
bool Publish (T msg, Guid theHostId)
 publishes the message in the underlying topic and calls SendToSocket if the given hostId is the local host id (see constructor) More...
 
bool Publish (T msg)
 publishes the message in the underlying topic and calls SendToSocket More...
 
- Public Member Functions inherited from ExitGames.Concurrency.Channels.ISubscriber< T >
IDisposable SubscribeToKeyedBatch< K > (IFiber fiber, Converter< T, K > keyResolver, Action< IDictionary< K, T >> receive, int intervalInMs)
 

Properties

Concurrency.Channels.IChannel< T > UnderlyingChannel [get]
 Gets the wrapped Concurrency.Channels.IChannel<T>. More...
 
- Properties inherited from ExitGames.Messaging.Channels.TopicPublisher< T >
Guid HostId [get]
 Gets the host id. The host id is added to each TopicMessage to enable the TopicMessageReceiver to filter messages on the same host. More...
 
IMessageSerializer< T > MessageSerializer [get]
 Gets the message serializer. The serializer converts a message to a byte array before sending them to the socket. More...
 
string Topic [get]
 Gets the topic. The topic is used to distinguish between different message types that are received and sent on the same socket. More...
 
Concurrency.Channels.IPublisher< T > UnderlyingPublisher [get]
 Gets the underlying publisher which is usally a Channel<T>. More...
 

Detailed Description

A Concurrency.Channels.IChannel<T> wrapper that extends class TopicPublisher<T>.

Template Parameters
TThe message type.

All instance members are thread safe if all constructor parameters are thread safe, too.

Constructor & Destructor Documentation

ExitGames.Messaging.Channels.TopicPublishChannel< T >.TopicPublishChannel ( string  topic,
Concurrency.Channels.IChannel< T >  channel,
ISocketSender  socketSender,
IMessageSerializer< T >  serializer,
Guid  hostId 
)
inline

Initializes a new instance of the TopicPublishChannel<T> class.

Parameters
topicThe topic is used to distinguish between different message types that are received and sent on the same socket.
channelThe channel is usually a Channel<T>.
socketSenderThe socket sender sends the serialized TopicMessage to a socket.
serializerThe serializer converts a message to a byte array before sending them to the socket.
hostIdThe host id is added to each TopicMessage to enable the TopicMessageReceiver to filter messages of the same host.

Member Function Documentation

void ExitGames.Messaging.Channels.TopicPublishChannel< T >.ClearSubscribers ( )
inline

Removes all subscribers.

Implements ExitGames.Concurrency.Channels.ISubscriber< T >.

IDisposable ExitGames.Messaging.Channels.TopicPublishChannel< T >.Subscribe ( IFiber  fiber,
Action< T >  receive 
)
inline

Registers a callback on this channel that receives one message at a time.

Parameters
fiberThe fiber executes the callback.
receiveThe callback action.
Returns
A disposable subscription.

Implements ExitGames.Concurrency.Channels.ISubscriber< T >.

IDisposable ExitGames.Messaging.Channels.TopicPublishChannel< T >.SubscribeOnProducerThreads ( IProducerThreadSubscriber< T >  subscriber)
inline

Subscribes an IProducerThreadSubscriber<T> that is invoked when Publish is called.

Parameters
subscriberThe subscriber.
Returns
A disposable subscription.

Implements ExitGames.Concurrency.Channels.IChannel< T >.

IDisposable ExitGames.Messaging.Channels.TopicPublishChannel< T >.SubscribeToBatch ( IFiber  fiber,
Action< IList< T >>  receive,
int  intervalInMs 
)
inline

Registers a callback on this channel that receives a list of messages.

Parameters
fiberThe fiber executes the callback.
receiveThe callback action.
intervalInMsThe max delay in milliseconds until the callback is invoked after Publish is called.
Returns
A disposable subscription.

Implements ExitGames.Concurrency.Channels.ISubscriber< T >.

IDisposable ExitGames.Messaging.Channels.TopicPublishChannel< T >.SubscribeToKeyedBatch< TK > ( IFiber  fiber,
Converter< T, TK >  keyResolver,
Action< IDictionary< TK, T >>  receive,
int  intervalInMs 
)
inline

Registers a callback on this channel that receives a dictionary of messages.

Template Parameters
TKThe key type.
Parameters
fiberThe fiber executes the callback.
keyResolverThe key resolver maps messages to keys.
receiveThe callback action.
intervalInMsThe max delay in milliseconds until the callback is invoked after Publish is called.
Returns
A disposable subscription.
IDisposable ExitGames.Messaging.Channels.TopicPublishChannel< T >.SubscribeToLast ( IFiber  fiber,
Action< T >  receive,
int  intervalInMs 
)
inline

Registers a callback on this channel that receives the last message after a timeout.

Parameters
fiberThe fiber executes the callback.
receiveThe callback action.
intervalInMsThe max delay in milliseconds until the callback is invoked after Publish is called.
Returns
A disposable subscription.

Implements ExitGames.Concurrency.Channels.ISubscriber< T >.

Property Documentation

Gets the wrapped Concurrency.Channels.IChannel<T>.