コード例 #1
0
 public override async Task <bool> ValidateConnection(RemoteConnectionAuthenticationTokenModel authToken)
 {
     return(await this.AsyncWrapper <bool>(async() =>
     {
         HttpResponseMessage response = await this.PostAsync("authentication/validateconnection", AdvancedHttpClient.CreateContentFromObject(authToken));
         return response.IsSuccessStatusCode;
     }));
 }
コード例 #2
0
 public abstract Task <bool> ValidateConnection(RemoteConnectionAuthenticationTokenModel authToken);
コード例 #3
0
 public abstract Task <bool> InitializeConnection(RemoteConnectionAuthenticationTokenModel connection);
コード例 #4
0
        public override async Task <bool> InitializeConnection(RemoteConnectionAuthenticationTokenModel connection)
        {
            if (!this.IsConnected)
            {
                if (!await this.ValidateConnection(connection))
                {
                    return(false);
                }

                this.AuthenticationToken = connection;

                this.ListenForRequestProfiles(async(clientID) =>
                {
                    try
                    {
                        RemoteConnectionModel clientConnection = ChannelSession.Settings.RemoteClientConnections.FirstOrDefault(c => c.ID.Equals(clientID));
                        if (clientConnection != null)
                        {
                            await this.SendProfiles(ChannelSession.Settings.RemoteProfiles.Where(p => !p.IsStreamer || clientConnection.IsStreamer));
                            ChannelSession.Services.Telemetry.TrackRemoteSendProfiles(connection.ID);
                        }
                    }
                    catch (Exception ex) { Logger.Log(ex); }
                });

                this.ListenForRequestBoard(async(clientID, profileID, boardID) =>
                {
                    try
                    {
                        RemoteConnectionModel clientConnection = ChannelSession.Settings.RemoteClientConnections.FirstOrDefault(c => c.ID.Equals(clientID));
                        if (clientConnection != null)
                        {
                            if (ChannelSession.Settings.RemoteProfileBoards.ContainsKey(profileID) && ChannelSession.Settings.RemoteProfileBoards[profileID].Boards.ContainsKey(boardID))
                            {
                                await this.SendBoard(ChannelSession.Settings.RemoteProfileBoards[profileID].Boards[boardID]);
                                ChannelSession.Services.Telemetry.TrackRemoteSendBoard(connection.ID, profileID, boardID);
                            }
                            else
                            {
                                await this.SendBoard(null);
                            }
                        }
                    }
                    catch (Exception ex) { Logger.Log(ex); }
                });

                this.ListenForSendCommand(async(clientID, commandID) =>
                {
                    try
                    {
                        RemoteConnectionModel clientConnection = ChannelSession.Settings.RemoteClientConnections.FirstOrDefault(c => c.ID.Equals(clientID));
                        if (clientConnection != null)
                        {
                            CommandBase command = ChannelSession.AllEnabledCommands.FirstOrDefault(c => c.ID.Equals(commandID));
                            if (command != null)
                            {
                                await command.Perform();
                            }
                        }
                    }
                    catch (Exception ex) { Logger.Log(ex); }
                });

                await this.Connect();

                await this.Authenticate(connection.ID, ChannelSession.Services.Secrets.GetSecret("RemoteHostSecret"), connection.AccessToken);

                await Task.Delay(3000);

                if (this.IsConnected)
                {
                    ChannelSession.Services.Telemetry.TrackRemoteAuthentication(connection.ID);
                }

                return(this.IsConnected);
            }
            return(true);
        }