public SapphireRedisSyncModule(RedisStore redisStore, SapphireDatabaseOptions options) { this.options = options; redisMultiplexer = redisStore.RedisCache.Multiplexer; redisMultiplexer.GetSubscriber().Subscribe($"{options.Sync.Prefix}sapphiresync/*", (channel, message) => { string channelPath = channel.ToString().Split('/').LastOrDefault(); switch (channelPath) { case "changes": SendChangesRequest changesRequest = JsonConvert.DeserializeObject <SendChangesRequest>(message); SyncRequestRequestReceived?.Invoke(changesRequest); break; case "publish": SendPublishRequest publishRequest = JsonConvert.DeserializeObject <SendPublishRequest>(message); SyncRequestRequestReceived?.Invoke(publishRequest); break; case "message": SendMessageRequest messageRequest = JsonConvert.DeserializeObject <SendMessageRequest>(message); SyncRequestRequestReceived?.Invoke(messageRequest); break; } }); }
public void Received(SyncRequest syncRequest) { SyncRequestRequestReceived?.Invoke(syncRequest); }