Пример #1
0
        private void SendMessageAsync()
        {
            var task = new Task(() =>
            {
                var symConfigLoader = new SymConfigLoader();
                var configPathTwo   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "testConfigPsdevTwo.json");
                var symConfigTwo    = symConfigLoader.loadFromFile(configPathTwo);
                var botAuthTwo      = new SymBotRSAAuth(symConfigTwo);
                botAuthTwo.authenticate();
                var botClientTwo = SymBotClient.initBot(symConfigTwo, botAuthTwo);

                // Find one BOT stream id
                var streamClient = botClientTwo.getStreamsClient();
                var streamTypes  = new List <string>
                {
                    "ROOM"
                };
                var result = streamClient.getUserStreams(streamTypes, false);
                // Send to that stream a messages
                var message = new OutboundMessage
                {
                    message = "<messageML>Hello world! From .NET SDK Integration Test.</messageML>"
                };
                var stream = new apiClientDotNet.Models.Stream
                {
                    streamId = result[0].id
                };
                var messageClient = new MessageClient(botClientTwo);
                messageClient.sendMessage(stream.streamId, message, false);
            }, TaskCreationOptions.AttachedToParent);

            task.Start();
        }
Пример #2
0
        static void Main(string[] args)
        {
            SymConfig     symConfig = new SymConfigLoader().loadFromFile("config.json");
            SymBotRSAAuth botAuth   = new SymBotRSAAuth(symConfig);

            botAuth.authenticate();
            SymBotClient botClient = SymBotClient.initBot(symConfig, botAuth);

            // start listening for messages
            DatafeedEventsService dataFeedService = botClient.getDatafeedEventsService();
            BotLogic listener = new BotLogic(botClient);

            dataFeedService.addIMListener(listener);
            dataFeedService.getEventsFromDatafeed();
        }
        public void ForGivenRsaConfig_CanAuthenticateAndCreateDataFeed()
        {
            var symConfig       = new SymConfig();
            var symConfigLoader = new SymConfigLoader();
            var configPath      = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "config.json");

            symConfig = symConfigLoader.loadFromFile(configPath);
            var botAuth = new SymBotRSAAuth(symConfig);

            botAuth.authenticate();
            var botClient = SymBotClient.initBot(symConfig, botAuth);
            DatafeedEventsService datafeedEventsService = botClient.getDatafeedEventsService();

            Assert.IsNotNull(datafeedEventsService.datafeedId);
        }
        public static void Setup(TestContext conext)
        {
            // Load integration test settings
            var integrationConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "integration.parameters.json");

            config = new ConfigurationBuilder().AddJsonFile(integrationConfigPath).Build();

            // Create SymBotClient
            var symConfigLoader = new SymConfigLoader();

            attachmentTestPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "AttachmentTest.txt");
            var configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "config.json");
            var symConfig  = symConfigLoader.loadFromFile(configPath);
            var botAuth    = new SymBotRSAAuth(symConfig);

            botAuth.authenticate();
            botClient = SymBotClient.initBot(symConfig, botAuth);
        }
Пример #5
0
        public void ChatBotTest()
        {
            var symConfigLoader = new SymConfigLoader();
            var configPath      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "config.json");
            var symConfig       = symConfigLoader.loadFromFile(configPath);
            var symBotRsaAuth   = new SymBotRSAAuth(symConfig);

            symBotRsaAuth.authenticate();
            symBotClient = SymBotClient.initBot(symConfig, symBotRsaAuth);

            // create data feed for the BOT
            var datafeedEventsService = new DatafeedEventsService(symBotClient);
            var botRoomListener       = new ChatRoomListener();
            var directChatListener    = new DirectChatListener();

            datafeedEventsService.addRoomListener(botRoomListener);
            datafeedEventsService.addIMListener(directChatListener);

            // start reading the data feed
            datafeedEventsService.getEventsFromDatafeed();
        }
Пример #6
0
        public void ChatBotTest()
        {
            var symConfigLoader = new SymConfigLoader();
            var configPathOne   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "config.json");
            var symConfigOne    = symConfigLoader.loadFromFile(configPathOne);
            var botAuthOne      = new SymBotRSAAuth(symConfigOne);

            botAuthOne.authenticate();
            var botClientOne = SymBotClient.initBot(symConfigOne, botAuthOne);

            // create data feed with bot One
            var datafeedEventsServiceBotOne = new DatafeedEventsService(botClientOne);
            var botLogic = new BotLogic(datafeedEventsServiceBotOne);

            datafeedEventsServiceBotOne.addRoomListener(botLogic);

            // Send message using bot two in a room where bot one is also added
            SendMessageAsync();

            // start reading the data feed and stop when the first message is received
            datafeedEventsServiceBotOne.getEventsFromDatafeed();
        }
Пример #7
0
        public static void Init(TestContext context)
        {
            // Load integration test settings
            var integrationConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "integration.parameters.json");

            config = new ConfigurationBuilder().AddJsonFile(integrationConfigPath).Build();

            // Create SymBotClient
            var symConfig       = new SymConfig();
            var symConfigLoader = new SymConfigLoader();
            var configPath      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "config.json");

            symConfig = symConfigLoader.loadFromFile(configPath);
            var botAuth = new SymBotRSAAuth(symConfig);

            botAuth.authenticate();
            symBotClient = SymBotClient.initBot(symConfig, botAuth);

            var userReceiverEmail = config.GetSection(typeof(ConnectionsClientIntegrationTest).Name).GetSection("test_email_address_user_receiver").Value;

            UserClient userClient = new UserClient(symBotClient);

            userReceiver = userClient.getUserFromEmail(userReceiverEmail, false)[0];
        }