コード例 #1
0
        private async Task GetLatestStreamSession()
        {
            IEnumerable <StreamSessionsAnalyticModel> sessions = await ChannelSession.Connection.GetStreamSessions(ChannelSession.Channel, DateTimeOffset.Now.Subtract(TimeSpan.FromDays(1)));

            sessions = sessions.OrderBy(s => s.dateTime);
            if (sessions.Count() > 0 && sessions.Last().duration == null)
            {
                StreamSessionsAnalyticModel latestSession = sessions.Last();
                UptimeChatCommand.SetUptime(latestSession.dateTime);
            }
        }
コード例 #2
0
 public UptimeChatCommand()
     : base(MixItUp.Base.Resources.Uptime, "uptime", 5, UserRoleEnum.User)
 {
     this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) =>
     {
         if (ChannelSession.Services.Chat != null)
         {
             DateTimeOffset startTime = await UptimeChatCommand.GetStartTime();
             if (startTime > DateTimeOffset.MinValue)
             {
                 TimeSpan duration = DateTimeOffset.Now.Subtract(startTime);
                 await ChannelSession.Services.Chat.SendMessage("Start Time: " + startTime.ToString("MMMM dd, yyyy - h:mm tt") + ", Stream Length: " + (int)duration.TotalHours + duration.ToString("\\:mm"));
             }
             else
             {
                 await ChannelSession.Services.Chat.SendMessage("Stream is currently offline");
             }
         }
     }));
 }