|
|
|
|
<redisConnection>.Subscribe (Function) In french: <redisConnexion>.Abonne 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 PROCÉDURE OnRedis(nType is int, sChannel is string, bufMessage is Buffer) SWITCH nType CASE redisSubscribe Trace("Subscription to " + sChannel) CASE redisUnsubscribe Trace("Cancel subscription to " + sChannel) CASE redisDisconnection Trace("Disconnection: " + sChannel) CASE redisMessage Trace("Message on " + sChannel+": " + UTF8ToString(bufMessage)) OTHER CASE Trace("Unknown") END END  gRedis.Subscribe("MyChannel", OnRedis) Syntax
<Result> = <Connection>.Subscribe(<Channel> , <WLanguage procedure>)
<Result>: Boolean - 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: - when a message is received,
- when subscribing,
- when unsubscribing,
- when disconnecting.
This procedure makes it possible to manage the current message. It will be called in a specific thread. 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 channel> 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
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|