Subscribes to a Redis broadcast channel. The application will then be notified about messages sent by applications connected to the Redis server that publishes messages on that channel.
INTERNAL PROCEDURE OnRedis(nType is int, sChannel is string, bufMessage is Buffer)
Trace("Subscription to " + sChannel)
Trace("Cancel subscription to " + sChannel)
Trace("Disconnection: " + sChannel)
Trace("Message on " + sChannel+": " + UTF8ToString(bufMessage))
RedisSubscribe(gRedis, "MyChannel", OnRedis)
<Result> = RedisSubscribe(<Connection> , <Channel> , <WLanguage procedure>)
- True is successfully subscribed,
- False otherwise.
<Connection>: redisConnection variable
Name of the redisConnection variable that corresponds to the Redis server connection.
<Channel>: Character string
Name of the broadcast channel to which it is necessary to subscribe in order to receive messages.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called:
This procedure makes it possible to manage the current message. It will be called in a specific thread.
- when a message is received,
- when subscribing,
- when unsubscribing,
- when disconnecting.
This procedure has the following format:
PROCEDURE <Procedure name>(<Type>, <Subscription channel>, <Message>)
- <Type> contains the type of message. This parameter corresponds to one of the following constants:
|redisDisconnection||The connection to the Redis server has been lost.|
If the procedure returns False, the application loses its subscription. Otherwise, the application will try to reconnect to the Redis server.
|redisMessage||The application has just received a message. In this case, <Message> contains the body of the message. |
|redisSubscription ||The application has just subscribed to <Subscription channel>. |
|redisUnsubscribe||The application has just unsubscribed from <Subscription channel>|
- <Subscription channelt> is a character string that contains the name of the channel to which the application subscribed.
- <Message> is a buffer that corresponds to the content of the message.
Business / UI classification: Business Logic