Exemplo n.º 1
0
        public DatafeedClient init(SymConfig symConfig)
        {
            roomListeners       = new List <RoomListener>();
            IMListeners         = new List <IMListener>();
            connectionListeners = new List <ConnectionListener>();
            datafeedClient      = new DatafeedClient();

            return(datafeedClient);
        }
Exemplo n.º 2
0
 public DatafeedEventsService(SymBotClient client)
 {
     this.botClient      = client;
     roomListeners       = new List <RoomListener>();
     IMListeners         = new List <IMListener>();
     connectionListeners = new List <ConnectionListener>();
     datafeedClient      = new DatafeedClient();
     datafeed            = datafeedClient.createDatafeed(client.getConfig());
     datafeedId          = datafeed.datafeedID;
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            string                filePath              = Path.GetFullPath("config.json");
            SymBotClient          symBotClient          = new SymBotClient();
            DatafeedEventsService datafeedEventsService = new DatafeedEventsService();
            SymConfig             symConfig             = symBotClient.initBot(filePath);
            RoomListener          botLogic              = new BotLogic();
            DatafeedClient        datafeedClient        = datafeedEventsService.init(symConfig);
            Datafeed              datafeed              = datafeedEventsService.createDatafeed(symConfig, datafeedClient);

            datafeedEventsService.addRoomListener(botLogic);
            datafeedEventsService.getEventsFromDatafeed(symConfig, datafeed, datafeedClient);
        }
Exemplo n.º 4
0
        static async Task <List <DatafeedEvent> > GetEventAsync(SymConfig symConfig, Datafeed datafeed, DatafeedClient datafeedClient)
        {
            RestRequestHandler   restRequestHandler = new RestRequestHandler();
            HttpWebResponse      response           = datafeedClient.getEventsFromDatafeed(symConfig, datafeed);
            List <DatafeedEvent> events             = null;

            if (response.StatusCode.Equals(HttpStatusCode.OK) || response.StatusCode.Equals(HttpStatusCode.Accepted))
            {
                try
                {
                    string body = restRequestHandler.ReadResponse(response);
                    events = JsonConvert.DeserializeObject <List <DatafeedEvent> >(body);
                }
                catch (JsonSerializationException e)
                {
                    Console.WriteLine("The file could not be read:");
                    Console.WriteLine(e.Message);
                }
            }
            else if (response.StatusCode.Equals(HttpStatusCode.Forbidden) || response.StatusCode.Equals(HttpStatusCode.Unauthorized))
            {
                //Add reauth
                stopLoop = true;
            }
            else if (response.StatusCode.Equals(HttpStatusCode.BadRequest))
            {
                stopLoop = true;
            }
            response.Close();
            return(events);
        }
Exemplo n.º 5
0
        static async Task <List <DatafeedEvent> > RunAsync(SymConfig symConfig, Datafeed datafeed, DatafeedClient datafeedClient)
        {
            List <DatafeedEvent> events = new List <DatafeedEvent>();

            try
            {
                events = await GetEventAsync(symConfig, datafeed, datafeedClient);

                return(events);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(events);
            }
        }
Exemplo n.º 6
0
        public Datafeed createDatafeed(SymConfig symConfig, DatafeedClient datafeedClient)
        {
            Datafeed datafeed = datafeedClient.createDatafeed(symConfig);

            return(datafeed);
        }