Phants Client for Redis™*
Classes | Public Member Functions | Protected Member Functions | Events | List of all members
SubscriptionClient Class Reference
Inheritance diagram for SubscriptionClient:
Inheritance graph
[legend]
Collaboration diagram for SubscriptionClient:
Collaboration graph
[legend]

Public Member Functions

delegate void SubscribedHandler (SubscriptionClient client, string channelName, long numSubscriptions)
 
delegate void UnsubscribedHandler (SubscriptionClient client, string channelName, long numSubscriptions)
 
delegate void PsubscribedHandler (SubscriptionClient client, string channelPattern, long numSubscriptions)
 
delegate void PunsubscribedHandler (SubscriptionClient client, string channelPattern, long numSubscriptions)
 
delegate void MessageHandler (SubscriptionClient client, string channelName, string messageContents)
 
delegate void PmessageHandler (SubscriptionClient client, string channelPattern, string channelName, string messageContents)
 
 SubscriptionClient (string hostname, int port, int recvBufferLen)
 
void Subscribe (params string[] channels)
 
void Unsubscribe (params string[] channels)
 
void Psubscribe (params string[] patterns)
 
void Punsubscribe (params string[] patterns)
 
void OnSubscribed (MessageParser parser, string channelName, long numSubscriptions)
 
void OnUnsubscribed (MessageParser parser, string channelName, long numSubscriptions)
 
void OnPsubscribed (MessageParser parser, string channelPattern, long numSubscriptions)
 
void OnPunsubscribed (MessageParser parser, string channelPattern, long numSubscriptions)
 
void OnMessage (MessageParser parser, string channelName, string messageContents)
 
void OnPmessage (MessageParser parser, string channelPattern, string channelName, string messageContents)
 
- Public Member Functions inherited from RedisClientBase
delegate void ConnectionCallback (RedisClientBase client, string error)
 
delegate void ConnectedEventHandler (RedisClientBase client)
 
delegate void DisconnectedEventHandler (RedisClientBase client)
 
 RedisClientBase (string hostname, int port)
 
void Connect (ConnectionCallback connectCallback=null)
 
void Disconnect (ConnectionCallback disconnectCallback=null)
 
bool Connected ()
 

Protected Member Functions

override void OnConnect (IAsyncResult connectResult)
 
- Protected Member Functions inherited from RedisClientBase
virtual void OnDisconnect (IAsyncResult disconnectResult)
 

Events

SubscribedHandler subscribed
 
UnsubscribedHandler unsubscribed
 
PsubscribedHandler psubscribed
 
PunsubscribedHandler punsubscribed
 
MessageHandler messaged
 
PmessageHandler pmessaged
 
- Events inherited from RedisClientBase
ConnectedEventHandler connected
 
DisconnectedEventHandler disconnected
 

Additional Inherited Members

- Protected Attributes inherited from RedisClientBase
string hostname
 
int port
 
Socket socket
 

Detailed Description

Redis has two modes of operation: a "command" mode, and a "pub/sub" mode. SubscriptionClient implements the latter, meaning users subscribe to channels and wait to receive messages. See pubsub for more information about the Redis publisher/subscriber model.

Constructor & Destructor Documentation

SubscriptionClient ( string  hostname,
int  port,
int  recvBufferLen 
)
inline

SubscriptionClient constructor.

Parameters
hostnameThe hostname or IP to connect to.
portThe port to connect to. Redis servers listen on 6379 by default.
recvBufferLenSubscriptionClient allocates a receive buffer internally; this parameter allows users to tailor the buffer size to fit their needs.

Member Function Documentation

delegate void MessageHandler ( SubscriptionClient  client,
string  channelName,
string  messageContents 
)

Delegate type for the messaged event.

override void OnConnect ( IAsyncResult  connectResult)
inlineprotectedvirtual

Callback used in calls to Socket.BeginConnect().

Reimplemented from RedisClientBase.

void OnMessage ( MessageParser  parser,
string  channelName,
string  messageContents 
)
inline

Called when a message of type "message" is received.

Parameters
parserThe MessageParser that parsed this message.
channelNameThe name of the originating channel.
messageContentsThe message payload.

Implements ResponseProcessor.

void OnPmessage ( MessageParser  parser,
string  channelPattern,
string  channelName,
string  messageContents 
)
inline

Called when a message of type "pmessage" is received.

Parameters
parserThe MessageParser that parsed this message.
channelPatternThe channel pattern that was matched.
channelNameThe name of the originating channel.
messageContentsThe message payload.

Implements ResponseProcessor.

void OnPsubscribed ( MessageParser  parser,
string  channelPattern,
long  numSubscriptions 
)
inline

Called when a message of type "psubscribed" is received.

Parameters
parserThe MessageParser that parsed this message.
channelPatternThe channel pattern that was matched.
numSubscriptionsThe number of channels this client is currently subscribed to.

Implements ResponseProcessor.

void OnPunsubscribed ( MessageParser  parser,
string  channelPattern,
long  numSubscriptions 
)
inline

Called when a message of type "punsubscribed" is received.

Parameters
parserThe MessageParser that parsed this message.
channelPatternThe channel pattern that was matched.
numSubscriptionsThe number of channels this client is currently subscribed to.

Implements ResponseProcessor.

void OnSubscribed ( MessageParser  parser,
string  channelName,
long  numSubscriptions 
)
inline

Called when a message of type "subscribed" is received.

Parameters
parserThe MessageParser that parsed this message.
channelNameThe name of the originating channel.
numSubscriptionsThe number of channels this client is currently subscribed to.

Implements ResponseProcessor.

void OnUnsubscribed ( MessageParser  parser,
string  channelName,
long  numSubscriptions 
)
inline

Called when a message of type "unsubscribed" is received.

Parameters
parserThe MessageParser that parsed this message.
channelNameThe name of the originating channel.
numSubscriptionsThe number of channels this client is currently subscribed to.

Implements ResponseProcessor.

delegate void PmessageHandler ( SubscriptionClient  client,
string  channelPattern,
string  channelName,
string  messageContents 
)

Delegate type for the pmessaged event.

void Psubscribe ( params string[]  patterns)
inline

Subscribe to all Redis channels with names matching the given regular expression.

Parameters
patternsRegular expression pattern(s) used to match channel names. Multiple patterns may be provided.

Example:

subClient.Psubscribe("event*");
delegate void PsubscribedHandler ( SubscriptionClient  client,
string  channelPattern,
long  numSubscriptions 
)

Delegate type for the psubscribed event.

void Punsubscribe ( params string[]  patterns)
inline

Unsubscribe from all Redis channels with names matching the given regular expression. If the patterns parameter is ommitted, the client will unsubscribe from all channels.

Parameters
patternsRegular expression pattern(s) used to match channel names. Zero or more patterns may be provided.

Example:

subClient.Punsubscribe("event*");
delegate void PunsubscribedHandler ( SubscriptionClient  client,
string  channelPattern,
long  numSubscriptions 
)

Delegate type for the punsubscribed event.

void Subscribe ( params string[]  channels)
inline

Subscribe to one or more Redis channels.

Parameters
channelsChannel name(s) being subscribed to.

Example:

subClient.Subscribe("event1", "event2", "foo", "bar");
delegate void SubscribedHandler ( SubscriptionClient  client,
string  channelName,
long  numSubscriptions 
)

Delegate type for the subscribed event.

void Unsubscribe ( params string[]  channels)
inline

Unsubscribe from one or more Redis channels. If the channels parameter is ommitted, the client will unsubscribe from all channels.

Parameters
channelsChannel name(s) being unsubscribed from. Zero or more channel names may be provided.

Example:

subClient.Unsubscribe("bar");
delegate void UnsubscribedHandler ( SubscriptionClient  client,
string  channelName,
long  numSubscriptions 
)

Delegate type for the unsubscribed event.

Event Documentation

MessageHandler messaged

Event fired whenever the user receives a message on a Subscribe()d channel.

PmessageHandler pmessaged

Event fired whenever the user receives a message on a Psubscribe()d channel.

PsubscribedHandler psubscribed

Event fired whenever the user Psubscribe()s (pattern subscribes) to a channel.

PunsubscribedHandler punsubscribed

Event fired whenever the user Punsubscribe()s (pattern unsubscribes) from a channel.

SubscribedHandler subscribed

Event fired whenever the user Subscribe()s to a channel.

UnsubscribedHandler unsubscribed

Event fired whenever the user Unsubscribe()s from a channel.


The documentation for this class was generated from the following file: