private void PollTracks()
        {
            if (TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow) > m_nextTrackPollTime)
            {
                Console.WriteLine("Polling tracks...");
                lock (m_trackLocker)
                {
                    m_tracks = HttpUtility.Get <Track[]>("https://spptqssmj8.execute-api.us-east-1.amazonaws.com/test/tracks?validation=valid");
                }

                lock (m_displayTrackLocker)
                {
                    m_displayTracks = GetTracks().Select(t => new Trackmanagement.Track
                    {
                        Name       = t.TrackName,
                        Type       = t.TrackType,
                        Image      = string.Format("{0}\\{1}{2}", Reflex.LocalImagePath, t.TrackName, Path.GetExtension(t.ThumbnailUrl)).Replace("\\", "/"),
                        Author     = t.Author,
                        Slot       = t.SlotNumber,
                        Date       = TimeUtility.UnixTimeStampToString(t.CreationTime),
                        Installs   = t.RatingVoteCount,
                        MyInstalls = GetMyInstalls(t.TrackName),
                        Favorite   = GetFavorite(t.TrackName),
                    }).ToArray();
                }

                m_nextTrackPollTime = TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow) + TrackPollTimeInSeconds;
            }
        }
Exemple #2
0
 private static void PollSharedTracks()
 {
     if (Reflex.OverlayIsVisible() && TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow) > m_nextPollTime)
     {
         lock (m_sharedTrackLocker)
         {
             m_sharedTracks = HttpUtility.Get <SharedReflexTracks[]>("https://spptqssmj8.execute-api.us-east-1.amazonaws.com/test/share");
         }
         m_nextPollTime = TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow) + TrackSharing.ServerPollingRateInSeconds;
     }
 }
Exemple #3
0
        public async Task FunctionHandler(DynamoDBEvent dynamoEvent, ILambdaContext context)
        {
            context.Logger.LogLine($"Beginning to process {dynamoEvent.Records.Count} records...");

            bool containsInsertRecord = false;

            //Search for an insert record
            foreach (var record in dynamoEvent.Records)
            {
                if (record.EventName == "INSERT")
                {
                    containsInsertRecord = true;
                    break;
                }
            }

            if (containsInsertRecord)
            {
                var  dynamoDbClient = new AmazonDynamoDBClient(RegionEndpoint.USEast1);
                var  dynamoContext  = new DynamoDBContext(dynamoDbClient);
                long currentTime    = TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow);
                long expiredTime    = currentTime - (TrackSharing.LifeSpanMinutes * 60);

                context.Logger.LogLine($"Looking for records older than {expiredTime}");
                var exipredItems = new List <ScanCondition>()
                {
                    new ScanCondition("CreationTime", ScanOperator.LessThanOrEqual, expiredTime)
                };
                var expiredItems = await dynamoContext.ScanAsync <TrackList>(exipredItems).GetRemainingAsync();

                foreach (var trackSet in expiredItems)
                {
                    context.Logger.LogLine($"Deleting {trackSet.Name}...");
                    var request = new DeleteItemRequest
                    {
                        TableName = "SharedReflexTrackLists",
                        Key       = new Dictionary <string, AttributeValue>()
                        {
                            { "Name", new AttributeValue {
                                  S = trackSet.Name
                              } }
                        },
                    };
                    var response = await dynamoDbClient.DeleteItemAsync(request);
                }
            }

            context.Logger.LogLine("Stream processing complete.");
        }
        public Reflex()
        {
            lock (m_trackLocker)
            {
                m_tracks = HttpUtility.Get <Track[]>("https://spptqssmj8.execute-api.us-east-1.amazonaws.com/test/tracks?validation=valid");
            }

            m_uiFiles = new string[]
            {
                "MXTables_DLC008.dx9.database"
                , "MXTables_DLC008.dx9.package"
                , "MXTables_DLC008a.dx9.database"
                , "MXTables_DLC008a.dx9.package"
                , "MXUI_DLC008.dx9.database"
                , "MXUI_DLC008.dx9.package"
            };
            m_reflexWasRunningLastFrame = false;
            m_nextTrackPollTime         = TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow) + TrackPollTimeInSeconds;
        }
Exemple #5
0
        private static void ShareTracks(string trackType)
        {
            try
            {
                var currentSharedList = HttpUtility.Get <SharedReflexTracks[]>("https://spptqssmj8.execute-api.us-east-1.amazonaws.com/test/share");
                var randomNames       = HttpUtility.Get <string[]>("http://names.drycodes.com/10?nameOptions=games");
                var trackSetName      = randomNames.Where(n => currentSharedList.Any(t => t.Name == n) == false).FirstOrDefault();
                if (trackSetName != null)
                {
                    var installedTracks = LocalSettings.GetTracks().Where(t => t.Installed && t.Type == trackType).Select(t => t.Name).ToArray();

                    SharedReflexTracks tracksToShare = new SharedReflexTracks
                    {
                        Name         = trackSetName,
                        Type         = trackType,
                        Tracks       = string.Join(",", installedTracks),
                        CreationTime = TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow)
                    };

                    bool success = HttpUtility.Post("https://spptqssmj8.execute-api.us-east-1.amazonaws.com/test/share", tracksToShare);
                    if (success)
                    {
                        Log.Add(Trackmanagement.LogMessageType.LogInfo, string.Format("Uploaded your {0} tracks as '{1}'. Tell your party to install it from the Shared Tracks Window.", trackType, trackSetName));
                        long nextShareTime = TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow) + TrackSharing.ShareRateLimitInSeconds;
                        m_shareRateLimiter[trackType] = nextShareTime;
                    }
                    else
                    {
                        Log.Add(Trackmanagement.LogMessageType.LogError, string.Format("An unexpected error occured attempting to share your {0} tracks.", trackType));
                    }
                }
                else
                {
                    Log.Add(Trackmanagement.LogMessageType.LogError, string.Format("Unable to share your {0} tracks because a unique name could not be generated. Please try again later.", trackType));
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
        }
Exemple #6
0
 public static void AddTracksToUploadQueue(string trackType)
 {
     try
     {
         if (TrackInstaller.InstallQueueIsEmpty)
         {
             if (TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow) >= m_shareRateLimiter[trackType])
             {
                 if (m_uploadQueue.Any(q => q == trackType) == false)
                 {
                     m_uploadQueue.Enqueue(trackType);
                     Log.Add(Trackmanagement.LogMessageType.LogInfo, string.Format("Added your '{0}' tracks to the upload queue.", trackType));
                 }
                 else
                 {
                     Log.Add(Trackmanagement.LogMessageType.LogWarning, string.Format("Your {0} tracks are already being uploaded. Please wait until the share process is complete.", trackType));
                 }
             }
             else
             {
                 var      endTime = TimeUtility.UnixTimeStampToDateTime(m_shareRateLimiter[trackType]);
                 TimeSpan ts      = endTime.Subtract(DateTime.UtcNow);
                 Log.Add(Trackmanagement.LogMessageType.LogWarning, string.Format("Share failed. You can share each track type once every {0} seconds.\n" +
                                                                                  " You will be able to share your {1} tracks again in {2} seconds", TrackSharing.ShareRateLimitInSeconds, trackType, (int)ts.TotalSeconds));
             }
         }
         else
         {
             Log.Add(Trackmanagement.LogMessageType.LogWarning, "Cannot share tracks until current install operation is complete.");
         }
     }
     catch (Exception e)
     {
         ExceptionLogger.LogException(e);
     }
 }