public void GetUserIDFromUserNameTest()
        {
            SymConfig       symConfig       = new SymConfig();
            SymConfigLoader symConfigLoader = new SymConfigLoader();

            symConfig = symConfigLoader.loadFromFile("C:/Users/Michael/Documents/Visual Studio 2017/Projects/apiClientDotNet/apiClientDotNetTest/Resources/testConfig.json");
            SymBotAuth botAuth = new SymBotAuth(symConfig);

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

            UserClient userClient = botClient.getUsersClient();
            UserInfo   user       = userClient.getUserFromUsername("mikepreview");

            StreamClient    streamClient    = botClient.getStreamsClient();
            RoomSearchQuery roomSearchQuery = new RoomSearchQuery();

            roomSearchQuery.query     = "APITestRoom";
            roomSearchQuery.active    = true;
            roomSearchQuery.isPrivate = true;
            NumericId id = new NumericId();

            id.id = user.id;
            roomSearchQuery.member = id;
            RoomSearchResult result = streamClient.searchRooms(roomSearchQuery, 0, 0);

            Assert.IsTrue(user != null);
        }
        public void MessageRoomTest()
        {
            SymConfig       symConfig       = new SymConfig();
            SymConfigLoader symConfigLoader = new SymConfigLoader();

            symConfig = symConfigLoader.loadFromFile("C:/Users/Michael/Documents/Visual Studio 2017/Projects/apiClientDotNet/apiClientDotNetTest/Resources/testConfig.json");
            SymBotAuth botAuth = new SymBotAuth(symConfig);

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

            message.message = "<messageML>Hello world!</messageML>";


            FileStream        fileStream  = File.OpenRead("C:/Users/Michael/Documents/Visual Studio 2017/Projects/apiClientDotNet/apiClientDotNetTest/Resources/AttachmentTest.txt");
            List <FileStream> attachments = new List <FileStream>();

            attachments.Add(fileStream);
            message.attachments = attachments;
            apiClientDotNet.Models.Stream stream = new apiClientDotNet.Models.Stream();
            stream.streamId = "fu1cJFoklnYlR9vu1AOZ5X___pzXDKPXdA";

            MessageClient  messageClient = new MessageClient(botClient);
            InboundMessage resp          = messageClient.sendMessage(stream.streamId, message, false);

            Assert.IsTrue(resp.messageId != null);
        }
Exemple #3
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();
        }
Exemple #4
0
        private void SendMessageTo(string name, Stream stream, Message message)
        {
            string        filePath      = Path.GetFullPath("config.json");
            SymBotClient  symBotClient  = new SymBotClient();
            SymConfig     symConfig     = symBotClient.initBot(filePath);
            MessageClient messageClient = new apiClientDotNet.MessageClient();

            messageClient.sendMessage(symConfig, message, stream);
        }
Exemple #5
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;
 }
Exemple #6
0
        public void onRoomMessage(Message inboundMessage)
        {
            string       filePath     = Path.GetFullPath("config.json");
            SymBotClient symBotClient = new SymBotClient();
            SymConfig    symConfig    = symBotClient.initBot(filePath);
            Message      message2     = new Message();

            message2.message = "<messageML> Hi " + inboundMessage.user.firstName + "!</messageML>";
            MessageClient messageClient = new apiClientDotNet.MessageClient();

            messageClient.sendMessage(symConfig, message2, inboundMessage.stream);
        }
Exemple #7
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);
        }
Exemple #8
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 DatafeedCreateTest()
        {
            SymConfig       symConfig       = new SymConfig();
            SymConfigLoader symConfigLoader = new SymConfigLoader();

            symConfig = symConfigLoader.loadFromFile("C:/Users/Michael/Documents/Visual Studio 2017/Projects/apiClientDotNet/apiClientDotNetTest/Resources/testConfig.json");
            apiClientDotNet.Authentication.SymBotAuth botAuth = new apiClientDotNet.Authentication.SymBotAuth(symConfig);
            botAuth.authenticate();
            SymBotClient          botClient             = SymBotClient.initBot(symConfig, botAuth);
            DatafeedEventsService datafeedEventsService = botClient.getDatafeedEventsService();

            //datafeedEventsService.getEventsFromDatafeed();

            //Assert.IsTrue(datafeedEventsService.datafeedId != null);
        }
        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);
        }
        public void UserListStreams()
        {
            SymConfig       symConfig       = new SymConfig();
            SymConfigLoader symConfigLoader = new SymConfigLoader();

            symConfig = symConfigLoader.loadFromFile("C:/Users/Michael/Documents/Visual Studio 2017/Projects/apiClientDotNet/apiClientDotNetTest/Resources/testConfig.json");
            SymBotAuth botAuth = new SymBotAuth(symConfig);

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

            StreamClient  streamClient = botClient.getStreamsClient();
            List <string> streamTypes  = new List <string>();

            streamTypes.Add("IM");
            streamTypes.Add("ROOM");
            List <StreamListItem> result = streamClient.getUserStreams(streamTypes, false);

            Assert.IsTrue(result != null);
        }
        public void SearchRoom()
        {
            SymConfig       symConfig       = new SymConfig();
            SymConfigLoader symConfigLoader = new SymConfigLoader();

            symConfig = symConfigLoader.loadFromFile("C:/Users/Michael/Documents/Visual Studio 2017/Projects/apiClientDotNet/apiClientDotNetTest/Resources/testConfig.json");
            SymBotAuth botAuth = new SymBotAuth(symConfig);

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

            StreamClient    streamClient    = botClient.getStreamsClient();
            RoomSearchQuery roomSearchQuery = new RoomSearchQuery();

            roomSearchQuery.query     = "APITestRoom";
            roomSearchQuery.active    = true;
            roomSearchQuery.isPrivate = true;
            RoomSearchResult result = streamClient.searchRooms(roomSearchQuery, 0, 0);

            Assert.IsTrue(result != null);
        }
Exemple #14
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();
        }
Exemple #15
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();
        }
Exemple #16
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];
        }
Exemple #17
0
 public BotLogic(SymBotClient symBotClient)
 {
     this.symBotClient = symBotClient;
 }