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

This is a IPublisher<T> wrapper that sends all messages as TopicMessage to a ISocketSender. More...

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

Public Member Functions

 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...
 

Properties

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

This is a IPublisher<T> wrapper that sends all messages as TopicMessage to a ISocketSender.

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.TopicPublisher< T >.TopicPublisher ( string  topic,
Concurrency.Channels.IPublisher< T >  publisher,
ISocketSender  socketSender,
IMessageSerializer< T >  serializer,
Guid  hostId 
)
inline

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

Parameters
topicThe topic is used to distinguish between different message types that are received and sent on the same socket.
publisherThe publisher 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

bool ExitGames.Messaging.Channels.TopicPublisher< T >.Publish ( msg,
Guid  theHostId 
)
inline

publishes the message in the underlying topic and calls SendToSocket if the given hostId is the local host id (see constructor)

Parameters
msgThe msg.
theHostIdThe host Id.
Returns
The publish.
bool ExitGames.Messaging.Channels.TopicPublisher< T >.Publish ( msg)
inline

publishes the message in the underlying topic and calls SendToSocket

Parameters
msgThe msg.
Returns
The publish.

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

void ExitGames.Messaging.Channels.TopicPublisher< T >.SendToSocket ( message)
inline

The message is serialized with the IMessageSerializer<T> and then sent as TopicMessage to the ISocketSender.

Parameters
messageThe message.

Property Documentation

Gets the host id. The host id is added to each TopicMessage to enable the TopicMessageReceiver to filter messages on the same host.

Gets the message serializer. The serializer converts a message to a byte array before sending them to the socket.

Gets the topic. The topic is used to distinguish between different message types that are received and sent on the same socket.

Gets the underlying publisher which is usally a Channel<T>.