public Publisher(KwwikaTweetStreamerPublisherConfig config) { KwwikaTweetStreamerPublisherConfig.CheckConfiguration(config); _logger = new LoggerWrapper(); _config = config; string twitterParams = BuildTwitterParams(config.SearchDefinitions); _connection = new TweetStreamer.Connection(config.TwitterConfig.Username, config.TwitterConfig.Password, config.TwitterConfig.Url, twitterParams, "POST", _logger); _connection.ConnectionStatusChanged += new TweetStreamer.Connection.OnConnectionStatusChangedEventHandler(connection_ConnectionStatusChanged); _connection.StatusMessageReceived += new TweetStreamer.Connection.OnStatusMessageReceivedEventHandler(connection_StatusMessageReceived); _messagePublisher = new MessagePublisherProxy(_logger, config); }
public static void CheckConfiguration(KwwikaTweetStreamerPublisherConfig config) { if (config.KwwikaConfig == null) { throw new ConfigurationErrorsException("KwwikaConfig must be defined"); } if (string.IsNullOrEmpty(config.KwwikaConfig.Domain) || string.IsNullOrEmpty(config.KwwikaConfig.ApiKey)) { throw new ConfigurationErrorsException("KwwikaConfig.Username and KwwikaConfig.Password must all be defined"); } if (config.TwitterConfig == null) { throw new ConfigurationErrorsException("TwitterConfig must be defined"); } if (string.IsNullOrEmpty(config.TwitterConfig.Password) || string.IsNullOrEmpty(config.TwitterConfig.Username) || string.IsNullOrEmpty(config.TwitterConfig.Url)) { throw new ConfigurationErrorsException("TwitterConfig.Username, TwitterConfig.Password and TwitterConfig.Url must all be defined"); } if (config.SearchDefinitions == null || config.SearchDefinitions.Length == 0) { throw new ConfigurationErrorsException("SearchDefinitions must be defined and at least one SearchDefinition must be defined"); } foreach (SearchDefinition def in config.SearchDefinitions) { if (string.IsNullOrEmpty(def.PublishTo)) { throw new ConfigurationErrorsException("SearchDefinition.PublishTo and SearchDefinition.TrackFor must all be defined"); } if(string.IsNullOrEmpty(def.TrackFor) && string.IsNullOrEmpty(def.FollowUsersWithId)) { throw new ConfigurationErrorsException("At least one of SearchDefinition.TrackFor or SearchDefinition.FollowUsersWithId must all be defined"); } } }
public MessagePublisherProxy(LoggerWrapper logger, KwwikaTweetStreamerPublisherConfig config) { _publishers.Add(new LogOnlyPublisher(logger)); _publishers.Add(new PusherPublisher(logger)); _publishers.Add(new KwwikaPublisher(logger, config.KwwikaConfig.ApiKey, config.KwwikaConfig.Domain)); }