Example #1
0
        static void Main(string[] args)
        {
            // Create a new DataSift client
            var client = new DataSiftClient("DATASIFT_USERNAME", "DATASIFT_APIKEY");

            // Compile filter
            var csdl = @"tag.brand ""Calvin Klein"" { interaction.content contains ""Calvin Klein"" }
                tag.brand ""GQ"" { interaction.content contains ""GQ"" }
                tag.brand ""Adidas"" { interaction.content contains ""Adidas"" }
            
                return
                {
                    interaction.content contains_any ""Calvin Klein, GQ, Adidas""
                }";

            var compiled = client.Compile(csdl);

            _hash = compiled.Data.hash;

            _stream                    = client.Connect();
            _stream.OnConnect         += stream_OnConnect;
            _stream.OnMessage         += stream_OnMessage;
            _stream.OnDelete          += stream_OnDelete;
            _stream.OnDataSiftMessage += stream_OnDataSiftMessage;
            _stream.OnClosed          += stream_OnClosed;

            // Wait for key press before ending example
            Console.WriteLine("-- Press any key to exit --");
            Console.ReadKey(true);
        }
Example #2
0
        internal static void Run(string username, string apikey)
        {
            _client = new DataSiftClient(username, apikey);

            Console.WriteLine("Running 'Streaming' example...");

            _stream                    = _client.Connect();
            _stream.OnConnect         += stream_OnConnect;
            _stream.OnMessage         += stream_OnMessage;
            _stream.OnDataSiftMessage += stream_OnDataSiftMessage;
            _stream.OnSubscribed      += stream_OnSubscribed;
            _stream.OnError           += stream_OnError;
            _stream.OnClosed          += stream_OnClosed;
            _stream.OnDelete          += stream_OnDelete;
        }