示例#1
0
    /// <summary>
    /// Initializes an instance of <see cref="VideoClient"/>.
    /// </summary>
    public VideoClient(HttpClient http)
    {
        _controller = new VideoController(http);

        Streams        = new StreamClient(http);
        ClosedCaptions = new ClosedCaptionClient(http);
    }
        private async void OnEnable()
        {
            _cam          = Camera.main.transform;
            _lines        = GetComponent <BezierLineRenderer>();
            _lineRenderer = GetComponent <LineRenderer>();
            _plots        = PlotManager.Instance as PlotManager;
            _links        = LinkManager.Instance as LinkManager;

            await _plots.Initialized;
            await _links.Initialized;

            _client = StreamClient.Instance;

            Observable.Merge(
                _client.SelectedTypeRx,
                _client.SelectedIdRx.Select(_ => ""))
            .BatchFrame()
            .TakeUntilDisable(this)
            .Subscribe(_ => UpdateSelection());

            var cursor = FindObjectOfType <AnimatedCursor>();

            if (cursor)
            {
                transform.SetParent(cursor.transform, false);
            }
        }
        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);
        }
示例#4
0
 public GrblClient()
 {
     _streamClient                       = new StreamClient();
     _streamClient.ReadLines             = true;
     _messagePacker                      = new MessagePacker(_streamClient.RxData, _streamClient.TxData);
     _messagePacker.SaveRejectedRequests = true;
 }
 private void OnEnable()
 {
     _link   = GetComponentInParent <Link>();
     _client = StreamClient.Instance;
     _cam    = Camera.main.transform;
     _plots  = PlotManager.Instance as PlotManager;
 }
示例#6
0
        private static async Task SimpleMessageLoop(StreamClient streamClient, string streamId, string initialCursor)
        {
            string cursor = initialCursor;

            for (int i = 0; i < 10; i++)
            {
                GetMessagesRequest getMessagesRequest = new GetMessagesRequest
                {
                    StreamId = streamId,
                    Cursor   = cursor,
                    Limit    = 10
                };
                GetMessagesResponse getResponse = await streamClient.GetMessages(getMessagesRequest);

                // process the messages
                logger.Info($"Read {getResponse.Items.Count}");
                foreach (Message message in getResponse.Items)
                {
                    logger.Info($"{Encoding.UTF8.GetString(message.Key)} : {Encoding.UTF8.GetString(message.Value)}");
                }

                // getMessages is a throttled method; clients should retrieve sufficiently large message
                // batches, as to avoid too many http requests.
                await Task.Delay(1000);

                // use the next-cursor for iteration
                cursor = getResponse.OpcNextCursor;
            }
        }
        private void Awake()
        {
            _user             = StreamClient.Instance;
            _webclientManager = WebClientManager.Instance as WebClientManager;
            _link             = GetComponentInParent <Link>();
            _animator         = GetComponent <Animator>();

            Observable.Merge(
                _user.SelectedIdRx,
                _user.SelectedTypeRx.Select(v => 0),
                _user.ZenModeRx.Select(v => 0),
                _user.LookingAtIdRx,
                _user.LookingAtTypeRx.Select(v => 0)
                )
            .TakeUntilDestroy(this)
            .BatchFrame()
            .ObserveOnMainThread()
            .Subscribe(_ => UpdateOutline());


            WebClient.AllModelChange()
            .TakeUntilDisable(this)
            .Where(ev => ev.ChangedProperties.Contains("Owner"))
            .ObserveOnMainThread()
            .Subscribe(ev => SearchCurrentWebclient());

            Observable.Merge(WebClient.ModelCreated(), WebClient.ModelDestroyed())
            .TakeUntilDisable(this)
            .Subscribe(m => SearchCurrentWebclient());
            SearchCurrentWebclient();
        }
示例#8
0
        async void ConfigSignalRConnection()
        {
            connection = new HubConnectionBuilder()
                         .WithUrl("http://192.168.1.111:5000/CastHub")
                         .WithAutomaticReconnect()
                         .Build();
            connection.On <string, int, int, bool, int, int>("UpdateScreen", UpdateScreen);
            wpfChatForm1.adds();
            await connection.StartAsync();

            await connection.InvokeAsync("SetName", myname);

            group = pass = await connection.InvokeAsync <string>("GetGroupId", logger.room_name);

            await connection.InvokeAsync("AddToGroup", group);

            port = await connection.InvokeAsync <int>("getport", group);

            await connection.InvokeAsync("getscreen");

            await connection.InvokeAsync("getMessages");

            sc = new StreamClient(port, "192.168.1.111");
            sc.Init();
            sc.ConnectToServer();
        }
示例#9
0
 public TransactionsStreamApi(StreamClient client, AccountId accountId) : base(client, request)
 {
     request = new TransactionStreamEndpointRequest()
     {
         AccountId = accountId
     };
 }
示例#10
0
        /// <summary>
        /// Initializes an instance of <see cref="VideoClient"/>.
        /// </summary>
        internal VideoClient(YoutubeHttpClient httpClient)
        {
            _httpClient = httpClient;

            Streams        = new StreamClient(httpClient);
            ClosedCaptions = new ClosedCaptionClient(httpClient);
        }
示例#11
0
        private void OnEnable()
        {
            _cam        = Camera.main.transform;
            _user       = StreamClient.Instance;
            _links      = LinkManager.Instance as LinkManager;
            _plots      = PlotManager.Instance as PlotManager;
            _webclients = WebClientManager.Instance as WebClientManager;

            // use timeout when creating links
            Link.AllModelChange()
            .Where(ev => ev.Model.CreatedBy == _user.Id && ev.ChangedProperties.Contains("CreatedBy"))
            .Subscribe(ev =>
            {
                _isCreatingLink = true;
                ResetProgress();
                ev.Model.CreatedByRx
                .Where(v => v < 0)
                .Take(1)
                .Delay(TimeSpan.FromSeconds(1))
                .Subscribe(v => _isCreatingLink = false, () => _isCreatingLink = false);
            });

            _user.LookingAtIdRx
            .TakeUntilDisable(this)
            .ObserveOnMainThread()
            .Subscribe(_ => ResetProgress());

            _user.LookingAtTypeRx
            .TakeUntilDisable(this)
            .ObserveOnMainThread()
            .Subscribe(_ => ResetProgress());

            Link.AllModelChange()
            .TakeUntilDisable(this)
            .Where(ev => ev.Model.CreatedBy == _user.Id)
            .Subscribe(_ => ResetProgress());

            // disable & reset progress during zen mode
            _user.ZenModeRx
            .TakeUntilDisable(this)
            .Where(v => v && !(_tablet && _tablet.IsVoiceActive))
            .ObserveOnMainThread()
            .Subscribe(_ => ResetProgress());

            Plot.AllModelChange()
            .TakeUntilDisable(this)
            .Where(ev => ev.ChangedProperties.Contains("BoundTo") && _tablet != null && ev.Model.BoundTo == _tablet.Id)
            .Subscribe(_ => ResetProgress());


            WebClient.AllModelChange()
            .TakeUntilDisable(this)
            .Where(ev => ev.ChangedProperties.Contains("Owner"))
            .Subscribe(ev => SearchCurrentTablet());

            Observable.Merge(WebClient.ModelCreated(), WebClient.ModelDestroyed())
            .TakeUntilDisable(this)
            .Subscribe(m => SearchCurrentTablet());
        }
        public YoutubeVideoDownloader()
        {
            var ytClient = new YoutubeClient();

            _streamClient   = ytClient.Videos.Streams;
            _playlistClient = ytClient.Playlists;
            _videoClient    = ytClient.Videos;
        }
示例#13
0
 public StreamClient getStreamsClient()
 {
     if (streamClient == null)
     {
         streamClient = new StreamClient(this);
     }
     return(streamClient);
 }
示例#14
0
        public void TokenIsValid()
        {
            var client = new StreamClient("key", "gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy");

            var feed = client.Feed("flat", "1");

            Assert.AreEqual("iFX1l5f_lIUWgZFBnv5UisTTW18", feed.Token);
        }
示例#15
0
    private void ApplyTransformationMatrix(StreamClient client)
    {
        var matrix    = client.OffsetMatrix.inverse;
        var rotOffset = MathUtility.QuaternionFromMatrix(matrix);

        transform.position = MathUtility.PositionFromMatrix(matrix) + rotOffset * transform.parent.localPosition;
        transform.rotation = rotOffset * transform.parent.localRotation;
    }
示例#16
0
        public void ReadOnlyTokenIsValid()
        {
            var client = new StreamClient("key", "gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy");

            var feed  = client.Feed("flat", "1");
            var token = feed.ReadOnlyToken;

            Assert.AreEqual("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZSI6IioiLCJhY3Rpb24iOiIqIiwiZmVlZF9pZCI6ImZsYXQxIn0.7435I3bhISLU2RdVeVVMtmjhLE7LPHvDgqQ6mnfFwhU", token);
        }
示例#17
0
 public PricingStreamApi(StreamClient client, AccountId accountId, ICollection <InstrumentName> instruments, bool?snapshot = null) : base(client, request)
 {
     request = new PricingStreamEndpointRequest()
     {
         AccountId   = accountId,
         Instruments = instruments,
         Snapshot    = snapshot
     };
 }
 private void OnEnable()
 {
     _streamClient                 = StreamClient.Instance;
     _webClientManager             = WebClientManager.Instance as WebClientManager;
     _hololensRoomscaleCalibration = FindObjectOfType <RoomscaleHololensCalibration>();
     _hololensSingleCalibration    = FindObjectOfType <LegacyHololensCalibration>();
     _webClientCalibration         = FindObjectOfType <WebClientCalibration>();
     _vuforiaBehaviour             = FindObjectOfType <VuforiaBehaviour>();
 }
 public DomoClient(IDomoConfig config)
 {
     _config  = config;
     Datasets = new DatasetClient(_config);
     Groups   = new GroupClient(_config);
     Pages    = new PageClient(_config);
     Streams  = new StreamClient(_config);
     Users    = new UserClient(_config);
 }
示例#20
0
        public void ReadOnlyTokenIsValid()
        {
            var client = new StreamClient("key", "gthc2t9gh7pzq52f6cky8w4r4up9dr6rju9w3fjgmkv6cdvvav2ufe5fv7e2r9qy");

            var feed  = client.Feed("flat", "1");
            var token = feed.ReadOnlyToken;

            Assert.AreEqual("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZSI6IioiLCJhY3Rpb24iOiIqIiwiZmVlZF9pZCI6ImZsYXQ6MSJ9.1gJgfGKbuOz793rYBlEFFICRHkM4a7a1VaEdelgYW9Y", token);
        }
示例#21
0
        private void Awake()
        {
            _tablet = GetComponentInParent <WebClient>();
            _user   = StreamClient.Instance;

            _tablet.ModelChange()
            .TakeUntilDestroy(this)
            .Subscribe(_ => UpdateCursor());
            UpdateCursor();
        }
示例#22
0
        private static Task <string> DownloadPlayerSourceAsync(this StreamClient streamClient, VideoId videoId, CancellationToken cancellationToken = default)
        {
            var        streamClientExposed      = Exposed.From(streamClient);
            HttpClient httpClient               = streamClientExposed._httpClient;
            var        youtubeControllerExposed = Exposed.From(streamClientExposed._controller);
            var        watchPageExposed         = Exposed.From(Exposed.From(youtubeControllerExposed.GetVideoWatchPageAsync(videoId, cancellationToken)).Result);
            string     playerSourceUrl          = watchPageExposed.TryGetPlayerSourceUrl();

            return(httpClient.GetStringAsync(playerSourceUrl));
        }
        public static async Task MainNonRegionalClient()
        {
            logger.Info("Starting example");

            var    provider      = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
            string compartmentId = Environment.GetEnvironmentVariable("OCI_COMPARTMENT_ID");

            StreamAdminClient streamAdminClient = new StreamAdminClient(provider);
            StreamClient      streamClient      = new StreamClient(provider);
            string            streamId          = null;

            try
            {
                Stream stream = await GetOrCreateStream(streamAdminClient, compartmentId, STREAM_NAME, PARTITIONS);

                streamId = stream.Id;

                // Streams are assigned a specific endpoint url based on where they are provisioned.
                // Create a stream client using the provided message endpoint.
                streamClient.SetEndpoint(stream.MessagesEndpoint);

                // publish some messages to the stream
                await PublishExampleMessages(streamClient, streamId);

                // give the streaming service a second to propagate messages
                await Task.Delay(1000);

                // Use a cursor for getting messages
                // A cursor can be created at a given partition/offset.
                // This gives explicit offset management control to the consumer.
                logger.Info("Starting a simple message loop with a partition cursor");
                string partitionCursor = await GetCursorByPartition(streamClient, streamId, "0");
                await SimpleMessageLoop(streamClient, streamId, partitionCursor);
            }
            catch (Exception e)
            {
                logger.Error($"NonRegional client example failed: {e}");
            }
            finally
            {
                // Cleanup; remember to delete streams which are not in use.
                await DeleteStream(streamAdminClient, streamId);

                // Stream deletion is an asynchronous operation, give it some time to complete.
                GetStreamRequest getStreamRequest = new GetStreamRequest
                {
                    StreamId = streamId
                };
                streamAdminClient.Waiters.ForStream(getStreamRequest, Stream.LifecycleStateEnum.Deleted).Execute();

                streamAdminClient.Dispose();

                logger.Info("End example");
            }
        }
示例#24
0
        private void OnEnable()
        {
            _user       = StreamClient.Instance;
            _webclients = WebClientManager.Instance as WebClientManager;

            _image = GetComponent <Image>();
            _originalImageColor = _image.color;


            WebClient.AllModelChange()
            .TakeUntilDisable(this)
            .Where(ev => ev.ChangedProperties.Contains("Owner"))
            .Subscribe(ev => SearchCurrentTablet());
        }
        public void GetJpegStartAndEndPositions_BufferPrevStateBytesReadIsMoreThanBufferPrevStateLength_ThrowsInvalidOperationException()
        {
            // Arrange
            var client                  = new StreamClient();
            var buffer                  = new byte[100];
            var prevBufferState         = new byte[100];
            var bufferBytesread         = 100;
            var prevBufferStateByteRead = 101;

            // Act
            Action actMethod = () => client.GetJpegStartAndEndPositions(buffer, bufferBytesread, prevBufferState, prevBufferStateByteRead);

            // Assert
            Assert.ThrowsException <InvalidOperationException>(actMethod);
        }
        public void GetJpegStartAndEndPositions_NullCurrentBufferPassed_ThrowsArgumentNullException()
        {
            // Arrange
            var client = new StreamClient();

            byte[] buffer                  = null;
            var    prevBufferState         = new byte[100];
            var    bufferBytesread         = 100;
            var    prevBufferStateByteRead = 100;

            // Act
            Action actMethod = () => client.GetJpegStartAndEndPositions(buffer, bufferBytesread, prevBufferState, prevBufferStateByteRead);

            // Assert
            Assert.ThrowsException <ArgumentNullException>(actMethod);
        }
        private void Awake()
        {
            _user       = StreamClient.Instance;
            _webclients = WebClientManager.Instance as WebClientManager;

            WebClient.AllModelChange()
            .TakeUntilDestroy(this)
            .Where(ev => ev.ChangedProperties.Contains("Owner"))
            .Subscribe(ev => SearchCurrentTablet());

            Observable.Merge(WebClient.ModelCreated(), WebClient.ModelDestroyed())
            .TakeUntilDestroy(this)
            .Subscribe(m => SearchCurrentTablet());

            UpdateCursor();
        }
        public static void Run(
            [CosmosDBTrigger("db-local", "socialData", ConnectionStringSetting = "CosmosDBConnectionString", LeaseDatabaseName = "db-local", LeaseCollectionName = "leases", LeasesCollectionThroughput = 400)]
            IReadOnlyList <Document> changedFeedItems,
            TraceWriter log,
            ExecutionContext context)
        {
            log.Info($"Received {changedFeedItems.Count} Documents from change feed processor");
            var config = new ConfigurationBuilder()
                         .SetBasePath(context.FunctionAppDirectory)
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables()
                         .Build();

            // todo: parameterize these or add these to a constants file
            var streamAccessKey = config.GetSection("Values")["StreamAccessKey"];
            var streamSecret    = config.GetSection("Values")["StreamSecret"];
            var feedItem        = new FeedItem(FeedItem.NewsFeedItem);

            // todo: Parameterize this
            var feedGroup = "club_tournaments";
            var eplUser   = "******";

            log.Info($"Adding Feed Item with Title [{feedItem.Title}] to Stream feed [{eplUser}]");

            var streamClient = new StreamClient(streamAccessKey, streamSecret);

            try
            {
                log.Verbose(JsonConvert.SerializeObject(feedItem));

                // todo: read epl from a config file
                var eplFeed  = streamClient.Feed(feedGroup, eplUser);
                var activity = new Stream.Activity(actor: eplUser, verb: "post", @object: feedItem.Id.ToString())
                {
                    ForeignId = feedItem.Id.ToString(),
                    // todo: This works in the short term by allowing me to populate old articles
                    // at the appropriate time in the feed, but what about production?
                    Time = feedItem.DatePublished
                };
                eplFeed.AddActivity(activity);
            }
            catch (Exception e)
            {
                log.Error($"threw exception {e.Message} while creating a user for {feedGroup}");
            }
        }
示例#29
0
        private static async Task <string> GetCursorByPartition(StreamClient streamClient, string streamId, string partition)
        {
            logger.Info($"Creating a cursor for partition {partition}");

            CreateCursorDetails createCursorDetails = new CreateCursorDetails
            {
                Partition = partition,
                Type      = CreateCursorDetails.TypeEnum.TrimHorizon
            };
            CreateCursorRequest createCursorRequest = new CreateCursorRequest
            {
                StreamId            = streamId,
                CreateCursorDetails = createCursorDetails
            };
            CreateCursorResponse createCursorResponse = await streamClient.CreateCursor(createCursorRequest);

            return(createCursorResponse.Cursor.Value);
        }
示例#30
0
        private void Awake()
        {
            _target = GetComponentInParent <IInteractable>();
            _user   = StreamClient.Instance;

            Observable.Merge(_user.SelectedTypeRx, _user.SelectedIdRx.Select(_ => ""))
            .SampleFrame(1)
            .ObserveOnMainThread()
            .TakeUntilDestroy(this)
            .Subscribe(_ => UpdateEnabled());

            if (DisableOnZenMode)
            {
                _user.ZenModeRx
                .ObserveOnMainThread()
                .TakeUntilDestroy(this)
                .Subscribe(_ => UpdateEnabled());
            }
        }
示例#31
0
        /// <summary>
        /// Initializes a new instance of the StravaClient class.
        /// </summary>
        /// <param name="authenticator">The IAuthentication object that holds a valid Access Token.</param>
        /// <seealso cref="WebAuthentication"/>
        /// <seealso cref="StaticAuthentication"/>
        public StravaClient(IAuthentication authenticator)
        {
            if (authenticator != null)
            {
                _authenticator = authenticator;

                Activities = new ActivityClient(authenticator);
                Athletes = new AthleteClient(authenticator);
                Clubs = new ClubClient(authenticator);
                Gear = new GearClient(authenticator);
                Segments = new SegmentClient(authenticator);
                Streams = new StreamClient(authenticator);
                Uploads = new UploadClient(authenticator);
                Efforts = new EffortClient(authenticator);
                Stats = new StatsClient(authenticator);
            }
            else
            {
                throw new ArgumentException("The IAuthentication object must not be null.");
            }
        }