Пример #1
0
        private void PresenceView_NotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e)
        {
            var presenceView = (RemotePresenceView)sender;
            var request      = (CallbackRequest)presenceView.ApplicationContext;

            foreach (var notification in e.Notifications)
            {
                Debug.Assert(notification.PresentityUri.Equals(request.TargetUri, StringComparison.OrdinalIgnoreCase));

                if (notification.AggregatedPresenceState != null)
                {
                    PresenceState state        = notification.AggregatedPresenceState;
                    var           availability = state.Availability;
                    if (availability == PresenceAvailability.Online ||
                        availability == PresenceAvailability.IdleOnline)
                    {
                        string logmessage = string.Format(CultureInfo.InvariantCulture, "{0} became online", request.TargetUri);
                        this.Logger.Log(Logger.LogLevel.Verbose, logmessage);

                        this.InitiateCallback(request);
                    }

                    break;
                }
            }
        }
Пример #2
0
        void Update()
        {
            presenceController.UpdateCallbacks();

            launchStateTimer.Update();
            idleStateTimer.Update();

            float currentTime = Time.time;

            if (currentTime - lastUpdate > updateInterval || !initialized)
            {
                lastUpdate = currentTime;

                PresenceState previousState = state;

                state = UpdateState();

                if (!state.Equals(previousState) || !initialized)
                {
                    presenceController.UpdatePresence(state);
                }

                initialized = true;
            }
        }
        private JObject FormatPresenceContent(PresenceState state)
        {
            var now = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
            var obj = new JObject();

            obj.Add("presence", state.state);
            obj.Add("user_id", state.user_id);

            if (state.last_active_ts != 0)
            {
                obj.Add("last_active_ago", (int)Math.Round(now - state.last_active_ts));
            }

            if (state.status_msg != null && state.state != "offline")
            {
                obj.Add("status_msg", state.status_msg);
            }

            if (state.state == "online")
            {
                obj.Add("currently_active", state.currently_active);
            }

            return(obj);
        }
Пример #4
0
		public RoomStub(
			string parentClientID, 
			string guid,
			string name,
			string url, 
			bool pinned,
			bool starred,
			bool isStarredByDefault,
			bool pinable,
			bool starrable,
			bool selected, 
			bool guest, 
			int newMessages, 
			int totalMessages, 
			string latestItem, 
			string latestItemSeen, 
			string latestItemOld, 
			bool readOnly, 
			int listOrder,
			bool isPhotoChatRoom,
			bool isPrivateChatRoom,
			bool isNewPhotoAlertsRoom,
			PresenceState presence,
			string icon,
			string tokenDateTimeTicks,
			string token,
			bool hasArchive,
			bool hiddenFromRoomList,
			bool isStreamRoom)
		{
			this.parentClientID = parentClientID;
			this.guid = guid;
			this.name = name;
			this.url = url;
			this.pinned = pinned;
			this.starred = starred;
			this.isStarredByDefault = isStarredByDefault;
			this.pinable = pinable;
			this.starrable = starrable;
			this.selected = selected;
			this.guest = guest;
			this.newMessages = newMessages;
			this.totalMessages = totalMessages;
			this.latestItem = latestItem;
			this.latestItemSeen = latestItemSeen;
			this.latestItemOld = latestItemOld;
			this.readOnly = readOnly;
			this.listOrder = listOrder;
			this.isPhotoChatRoom = isPhotoChatRoom;
			this.isPrivateChatRoom = isPrivateChatRoom;
			this.isNewPhotoAlertsRoom = isNewPhotoAlertsRoom;
			this.presence = presence;
			this.icon = icon;
			this.tokenDateTimeTicks = tokenDateTimeTicks;
			this.token = token;
			this.hasArchive = hasArchive;
			this.hiddenFromRoomList = hiddenFromRoomList;
			this.isStreamRoom = isStreamRoom;

		}
Пример #5
0
        public void UpdatePresence(PresenceState state)
        {
            DiscordRpc.RichPresence presence = state.create();

            Debug.Log(string.Format("DiscordRP: Send presence: {0} ({1})", presence, state));

            DiscordRpc.UpdatePresence(ref presence);
        }
 public override bool Equals(object obj)
 {
     if (!(obj is TF2RichPresence other))
     {
         return(false);
     }
     return(PresenceState.Equals(other.PresenceState) &&
            Location.Equals(other.Location) &&
            CurrentMap?.Equals(other.CurrentMap) != false);
 }
Пример #7
0
        void Awake()
        {
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + PLUGIN_DIRECTORY);

            presenceController = new PresenceController();

            lastUpdate = Time.time;
            state      = new IdlingState(launchStateTimer.Timestamp);
            idleStateTimer.Update();
        }
Пример #8
0
        private void UpdatePresence(PresenceState state)
        {
            PresenceState previousState = this.state;

            this.state = state;

            if (!state.Equals(previousState) || !initialized)
            {
                presenceController.UpdatePresence(state);
            }
        }
Пример #9
0
        /// <summary>
        /// Called when the <see cref="GameStateListener"/> receives a new state.
        /// </summary>
        /// <param name="gameState">The new game state.</param>
        public void NewGameState(GameState gameState)
        {
            Safe(() =>
            {
                var newState = new PresenceState();

                newState.ImageValue = new ImageBundle("logo", "DOTA 2");

                newState.FieldValues["Kills"]    = gameState.Player.Kills.ToString();
                newState.FieldValues["Deaths"]   = gameState.Player.Deaths.ToString();
                newState.FieldValues["Assists"]  = gameState.Player.Assists.ToString();
                newState.FieldValues["Denies"]   = gameState.Player.Denies.ToString();
                newState.FieldValues["LastHits"] = gameState.Player.LastHits.ToString();
                newState.FieldValues["Team"]     = gameState.Player.Team.ToString();
                newState.FieldValues["Hero"]     = Utilities.Dota2HeroNaming.MakeFriendlyName(gameState.Hero.Name);
                newState.FieldValues["Level"]    = gameState.Hero.Level.ToString();
                newState.FieldValues["Gold"]     = gameState.Player.Gold.ToString("N0");

                // If we're in a game but haven't picked yet
                if (gameState.Hero.Level == -1)
                {
                    newState.OverrideText = ("Picking a hero", "");
                }

                // If they want no icon, create a blank icon
                newState.IconValues["None"] = new ImageBundle("", "");

                // If they want a team icon, find out which team they're on
                if (gameState.Player.Team == Dota2GSI.Nodes.PlayerTeam.Dire)
                {
                    newState.IconValues["Team"] = new ImageBundle("dire", "Dire");
                }
                else if (gameState.Player.Team == Dota2GSI.Nodes.PlayerTeam.Radiant)
                {
                    newState.IconValues["Team"] = new ImageBundle("radiant", "Radiant");
                }
                else
                {
                    newState.IconValues["Team"] = new ImageBundle("", "");
                }

                PushState(newState);
                _noStateTimer.Stop();
                _noStateTimer.Start();
            });
        }
Пример #10
0
        private void PresenceView_NotificationReceived(
            object sender,
            RemotePresentitiesNotificationEventArgs e)
        {
            lock (this.SyncRoot)
            {
                foreach (var notification in e.Notifications)
                {
                    ContactInformation info = null;
                    if (!m_contacts.TryGetValue(notification.PresentityUri, out info))
                    {
                        continue;
                    }

                    foreach (var category in notification.Categories)
                    {
                        if (category.Name == PresenceCategoryNames.ContactCard)
                        {
                            var card = new ContactCard(category);
                            info.AddContactCard(card);
                        }
                        else if (category.Name == PresenceCategoryNames.State)
                        {
                            string rawXml = category.Category.GetCategoryDataXml();
                            if (string.IsNullOrEmpty(rawXml))
                            {
                                continue;
                            }

                            PresenceState state = new PresenceState(category);

                            var availability = state.Availability;
                            if (availability != PresenceAvailability.None)
                            {
                                info.Availability = availability;
                            }
                        }
                    }
                }
            }
        }
Пример #11
0
 /// <summary>
 /// Set the online status.
 /// </summary>
 /// <param name="presenceStatus">The presence status.</param>
 public void SetOnlineStatus(PresenceState presenceStatus)
 {
     _account.SetOnlineStatus(presenceStatus);
 }
Пример #12
0
        /// <summary>
        /// PublishPresenceToWebCustomers is a method that indicates Web Users different levels of Presence based on
        /// the average queue time, or whether the portal is getting drained.
        /// </summary>
        private void PublishPresenceToWebCustomers()
        {
            //Limitation: Note that this publication only makes sense if only one instance of the Application is in service.
            // If multiple instances of the application were running at the same time, one shall consider using a database to coordinate the publication
            // of the information.

            PresenceState aggregateState;

            if (_portalState == PortalState.Started ||
                _portalState == PortalState.Draining)
            {
                if (_portalState == ContactCenter.PortalState.Started)
                {
                    TimeSpan averageWaitTime = _agentHunter.AverageQueueTime.Value;
                    if (averageWaitTime <= AcdPortal.OneMinuteSpan)
                    {
                        var presenceActivity = new PresenceActivity(new LocalizedString(1033, String.Format("Expected Wait Time is \r\n {0} min and {1} sec",
                                                                                                            averageWaitTime.Minutes,
                                                                                                            averageWaitTime.Seconds)));

                        presenceActivity.SetAvailabilityRange(3500, 3500);
                        aggregateState = new PresenceState(PresenceStateType.AggregateState,
                                                           3500,
                                                           presenceActivity);
                    }
                    else if (averageWaitTime <= AcdPortal.FiveMinuteSpan)
                    {
                        var presenceActivity = new PresenceActivity(new LocalizedString(1033, String.Format("Expected Wait Time is \r\n {0} min and {1} sec",
                                                                                                            averageWaitTime.Minutes,
                                                                                                            averageWaitTime.Seconds)));
                        presenceActivity.SetAvailabilityRange(6500, 6500);

                        aggregateState = new PresenceState(PresenceStateType.AggregateState,
                                                           6500,
                                                           presenceActivity);
                    }
                    else
                    {
                        string activityString = null;
                        if (averageWaitTime.Hours > 0)
                        {
                            activityString = String.Format("Expect Long Wait Time; \r\n currently {0} hour {1} min and {2} sec", averageWaitTime.Hours, averageWaitTime.Minutes, averageWaitTime.Seconds);
                        }
                        else
                        {
                            activityString = String.Format("Expect Long Wait Time; \r\n currently {0} min and {1} sec", averageWaitTime.Minutes, averageWaitTime.Seconds);
                        }

                        var presenceActivity = new PresenceActivity(new LocalizedString(1033, activityString));
                        presenceActivity.SetAvailabilityRange(6500, 6500);

                        aggregateState = new PresenceState(PresenceStateType.AggregateState,
                                                           6500,
                                                           presenceActivity);
                    }
                }
                else
                {
                    var presenceActivity = new PresenceActivity(new LocalizedString(1033, "This service is not available at this time; please call again later."));
                    presenceActivity.SetAvailabilityRange(9500, 9500);
                    aggregateState = new PresenceState(PresenceStateType.AggregateState,
                                                       9500,
                                                       presenceActivity);
                }

                PresenceCategoryWithMetaData averageQueueTimePublication = new PresenceCategoryWithMetaData(1,
                                                                                                            ContainerIDForWebUsers,
                                                                                                            aggregateState);

                try
                {
                    _endpoint.LocalOwnerPresence.BeginPublishPresence(new List <PresenceCategoryWithMetaData>()
                    {
                        averageQueueTimePublication
                    },
                                                                      pub =>
                    {
                        try
                        {
                            _endpoint.LocalOwnerPresence.EndPublishPresence(pub);
                        }

                        catch (OperationFailureException ofex)
                        {
                            _logger.Log("AcdPortal failed to end publish average queue time", ofex);
                        }
                        catch (PublishSubscribeException psex)
                        {
                            _logger.Log("AcdPortal failed to end publish average queue time", psex);
                        }
                        catch (RealTimeException rtex)
                        {
                            _logger.Log("AcdPortal failed to end publish average queue time", rtex);
                        }
                    },
                                                                      null);
                }
                catch (InvalidOperationException ivoex)
                {
                    _logger.Log("AcdPortal failed to begin publish average queue time", ivoex);
                }
            }
        }
Пример #13
0
        // Publish note, state, contact card presence categories
        private void PublishPresenceCategories(bool publishFlag, string status = null)
        {
            try
            {
                if (publishFlag == true)
                {
                    // The CustomPresenceCategory class enables creation of a
                    // category using XML. This allows precise crafting of a
                    // category, but it is also possible to create a category
                    // in other, more simple ways, shown below.
                    _note = new CustomPresenceCategory("note", String.Format(_noteXml, _noteValue));

                    switch (status)
                    {
                    default:     //Available
                        _userState = PresenceState.UserAvailable;
                        Console.WriteLine(DateTime.Now.ToString() + " Setting available status.");
                        // It is possible to create and publish state with a custom availablity string, shown below
                        LocalizedString localizedAvailableString = new LocalizedString("Available");

                        // Create a PresenceActivity indicating the "In a call" state.
                        PresenceActivity Available = new PresenceActivity(localizedAvailableString);

                        // Set the Availability of the "In a call" state to Busy.
                        Available.SetAvailabilityRange((int)PresenceAvailability.Online,
                                                       (int)PresenceAvailability.Online);

                        // Microsoft Lync will also show the Busy presence icon.
                        _phoneState = new PresenceState(
                            (int)PresenceAvailability.Online,
                            Available,
                            PhoneCallType.Voip,
                            "phone uri");
                        break;

                    case "Busy":     //Busy
                        Console.WriteLine(DateTime.Now.ToString() + " Setting busy status.");
                        _userState = PresenceState.UserBusy;
                        LocalizedString  localizedBusyString = new LocalizedString("Busy");
                        PresenceActivity Busy = new PresenceActivity(localizedBusyString);
                        Busy.SetAvailabilityRange((int)PresenceAvailability.Busy,
                                                  (int)PresenceAvailability.IdleBusy);
                        _phoneState = new PresenceState(
                            (int)PresenceAvailability.Busy,
                            Busy,
                            PhoneCallType.Voip,
                            "phone uri");
                        break;


                    case "In a call":     //In a call
                        Console.WriteLine(DateTime.Now.ToString() + " Setting in a call status.");
                        _userState = PresenceState.UserBusy;
                        LocalizedString  localizedCallString = new LocalizedString("In a call");
                        PresenceActivity inACall             = new PresenceActivity(localizedCallString);
                        inACall.SetAvailabilityRange((int)PresenceAvailability.Busy,
                                                     (int)PresenceAvailability.IdleBusy);
                        _phoneState = new PresenceState(
                            (int)PresenceAvailability.Busy,
                            inACall,
                            PhoneCallType.Voip,
                            "phone uri");
                        break;

                    case "In a meeting":     //In a meeting
                        Console.WriteLine(DateTime.Now.ToString() + " Setting in a meeting status.");
                        _userState = PresenceState.UserBusy;
                        LocalizedString  localizedMeetingString = new LocalizedString("In a meeting");
                        PresenceActivity inAMeeting             = new PresenceActivity(localizedMeetingString);
                        inAMeeting.SetAvailabilityRange((int)PresenceAvailability.Busy,
                                                        (int)PresenceAvailability.IdleBusy);
                        _phoneState = new PresenceState(
                            (int)PresenceAvailability.Busy,
                            inAMeeting,
                            PhoneCallType.Voip,
                            "phone uri");
                        break;

                    case "In a conference call":     //In a conference call
                        Console.WriteLine(DateTime.Now.ToString() + " Setting in a conference call status.");
                        _userState = PresenceState.UserBusy;
                        LocalizedString  localizedConferenceString = new LocalizedString("In a conference call");
                        PresenceActivity inAConference             = new PresenceActivity(localizedConferenceString);
                        inAConference.SetAvailabilityRange((int)PresenceAvailability.Busy,
                                                           (int)PresenceAvailability.IdleBusy);
                        _phoneState = new PresenceState(
                            (int)PresenceAvailability.Busy,
                            inAConference,
                            PhoneCallType.Voip,
                            "phone uri");
                        break;

                    case "Presenting":     //Presenting
                        Console.WriteLine(DateTime.Now.ToString() + " Setting presenting status.");
                        _userState = PresenceState.UserBusy;
                        LocalizedString  localizedPresentingString = new LocalizedString("Presenting");
                        PresenceActivity Presenting = new PresenceActivity(localizedPresentingString);
                        Presenting.SetAvailabilityRange((int)PresenceAvailability.Busy,
                                                        (int)PresenceAvailability.DoNotDisturb);
                        _phoneState = new PresenceState(
                            (int)PresenceAvailability.DoNotDisturb,
                            Presenting,
                            PhoneCallType.Voip,
                            "phone uri");
                        break;

                    case "Offline":     //Offline
                        Console.WriteLine(DateTime.Now.ToString() + " Setting offline status.");
                        _userState = PresenceState.UserOffline;
                        LocalizedString  localizedOfflineString = new LocalizedString("Offline");
                        PresenceActivity Offline = new PresenceActivity(localizedOfflineString);
                        Offline.SetAvailabilityRange((int)PresenceAvailability.Offline,
                                                     (int)PresenceAvailability.Offline);
                        _phoneState = new PresenceState(
                            (int)PresenceAvailability.Offline,
                            Offline,
                            PhoneCallType.Voip,
                            "phone uri");
                        break;
                    }

                    // Machine or Endpoint states must always be published to
                    // indicate the endpoint is actually online, otherwise it is
                    // assumed the endpoint is offline, and no presence
                    // published from that endpoint will be displayed.
                    _machineState = PresenceState.EndpointOnline;

                    // It is also possible to create presence categories such
                    // as ContactCard, Note, PresenceState, and Services with
                    // their constructors.
                    // Here we create a ContactCard and change the title.
                    _contactCard = new ContactCard(0);

                    /* The title string to be displayed. */
                    if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["UserTitle"]))
                    {
                        LocalizedString localizedTitleString = new LocalizedString(ConfigurationManager.AppSettings["UserTitle"]);
                        _contactCard.JobTitle = localizedTitleString.Value;
                    }

                    if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["UserOffice"]))
                    {
                        LocalizedString localizedTitleString = new LocalizedString(ConfigurationManager.AppSettings["UserOffice"]);
                        _contactCard.OfficeLocation = localizedTitleString.Value;
                    }

                    if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["JobTitle"]))
                    {
                        LocalizedString localizedTitleString = new LocalizedString(ConfigurationManager.AppSettings["JobTitle"]);
                        _contactCard.JobTitle = localizedTitleString.Value;
                    }
                    // Publish a photo
                    // If the supplied value for photo is null or empty, then set value of IsAllowedToShowPhoto to false
                    _contactCard.IsAllowedToShowPhoto = false;

                    string photoUri = ConfigurationManager.AppSettings["PhotoUri"];
                    if (!String.IsNullOrEmpty(photoUri))
                    {
                        _contactCard.IsAllowedToShowPhoto = true;
                        _contactCard.PhotoUri             = photoUri;
                    }

                    // Publish all presence categories with new values.
                    _localOwnerPresence.BeginPublishPresence(
                        new PresenceCategory[]
                    {
                        _userState,
                        _phoneState,
                        _machineState,
                        _note,
                        _contactCard
                    },
                        PublishPresenceCompleted, /* async callback when publishing operation completes. */
                        publishFlag /* value TRUE indicates that presence to be published with new values. */);
                }
                else
                {
                    // Delete all presence categories.
                    Console.WriteLine(DateTime.Now.ToString() + " Revert status back.");
                    _localOwnerPresence.BeginDeletePresence(
                        new PresenceCategory[]
                    {
                        _userState,
                        _phoneState,
                        _machineState,
                        _note,
                        _contactCard
                    },
                        PublishPresenceCompleted,
                        publishFlag /* value FALSE indicates that presence reverted to original values. */);
                }
            }
            catch (PublishSubscribeException pse)
            {
                // PublishSubscribeException is thrown when there were
                // exceptions during this presence operation such as badly
                // formed sip request, duplicate publications in the same
                // request etc.
                // TODO (Left to the reader): Include exception handling code
                // here.
                Console.WriteLine(pse.ToString());
            }
            catch (RealTimeException rte)
            {
                // RealTimeException is thrown when SIP Transport, SIP
                // Authentication, and credential-related errors are
                // encountered.
                // TODO (Left to the reader): Include exception handling code
                // here.
                Console.WriteLine(rte.ToString());
            }
        }
Пример #14
0
        /// <summary>
        /// Called when the <see cref="GameStateListener"/> receives a new state.
        /// </summary>
        /// <param name="gameState">The new game state.</param>
        public void NewGameState(GameState gameState)
        {
            Safe(() =>
            {
                var newState = new PresenceState();

                newState.ImageValue = new ImageBundle("logo", "CS:GO");

                // The game broadcasts a '-1' state when started
                if (gameState.Player.MatchStats.Deaths == -1)
                {
                    return;
                }

                // gameState.Player refers to the player we're watching, so if we're dead,
                // it's the person we're spectating
                // If the player isn't us, reset the timer but don't update any presence info
                if (gameState.Player.SteamID != gameState.Provider.SteamID)
                {
                    _noStateTimer.Stop();
                    _noStateTimer.Start();

                    return;
                }

                newState.FieldValues["Kills"]   = gameState.Player.MatchStats.Kills.ToString();
                newState.FieldValues["Deaths"]  = gameState.Player.MatchStats.Deaths.ToString();
                newState.FieldValues["Assists"] = gameState.Player.MatchStats.Assists.ToString();
                newState.FieldValues["MVPs"]    = gameState.Player.MatchStats.MVPs.ToString();
                newState.FieldValues["Map"]     = gameState.Map.Name;
                newState.FieldValues["Mode"]    = Utilities.GlobalOffensiveNaming.ModeNames[gameState.Map.Mode];

                // The Team and Score fields depend on your team
                switch (gameState.Player.Team)
                {
                case CSGSI.Nodes.PlayerTeam.T:
                    newState.FieldValues["Team"]  = "Terrorists";
                    newState.FieldValues["Score"] = $"T {gameState.Map.TeamT.Score} - {gameState.Map.TeamCT.Score} CT";
                    break;

                case CSGSI.Nodes.PlayerTeam.CT:
                    newState.FieldValues["Team"]  = "Counter-Terrorists";
                    newState.FieldValues["Score"] = $"CT {gameState.Map.TeamCT.Score} - {gameState.Map.TeamT.Score} T";
                    break;

                default:
                    newState.FieldValues["Team"]  = "Unknown team";
                    newState.FieldValues["Score"] = $"CT {gameState.Map.TeamCT.Score} - {gameState.Map.TeamT.Score} T";
                    break;
                }

                // If they want no icon, create a blank icon
                newState.IconValues["None"] = new ImageBundle("", "");

                // If they want a team icon, find out which team they're on
                if (gameState.Player.Team == CSGSI.Nodes.PlayerTeam.T)
                {
                    newState.IconValues["Team"] = new ImageBundle("t", "Terrorists");
                }
                else if (gameState.Player.Team == CSGSI.Nodes.PlayerTeam.CT)
                {
                    newState.IconValues["Team"] = new ImageBundle("ct", "Counter-Terrorists");
                }
                else
                {
                    newState.IconValues["Team"] = new ImageBundle("", "");
                }

                PushState(newState);
                _noStateTimer.Stop();
                _noStateTimer.Start();
            });
        }
Пример #15
0
		RoomStub getRoomStub(Guid g, string name, string url, bool pinnable, bool guest, bool readOnly, bool pinned, bool isPhotoChatRoom, bool isPrivateChatRoom, bool isNewPhotoAlertsRoom, PresenceState presence, string icon, bool starred, int listOrder, bool isStarredByDefault, bool starrable, bool hasArchive, bool hiddenFromRoomList, bool isStreamRoom)
		{
			string tokenDateTimeTicks = guest ? DateTime.Now.Ticks.ToString() : "";
			string token = guest ? Chat.GetToken(g, tokenDateTimeTicks) : "";
			return new RoomStub(
				this.ClientID,
				g.Pack(),//.ToString("N"),
				name,
				url,
				pinned,
				starred,
				isStarredByDefault,
				pinnable,
				starrable,
				false,//Prefs.Current["ChatClientSelectedRoomGuid"].Exists && Prefs.Current["ChatClientSelectedRoomGuid"].Equals(g.ToString("N")), 
				guest,
				0,
				0,
				"",
				"",
				"",
				readOnly,
				listOrder,
				isPhotoChatRoom,
				isPrivateChatRoom,
				isNewPhotoAlertsRoom,
				presence,
				icon,
				tokenDateTimeTicks,
				token,
				hasArchive,
				hiddenFromRoomList,
				isStreamRoom);
		}
Пример #16
0
        // Publish note, state, contact card presence categories
        private void PublishPresenceCategories(bool publishFlag)
        {
            try
            {
                if (publishFlag == true)
                {
                    // The CustomPresenceCategory class enables creation of a
                    // category using XML. This allows precise crafting of a
                    // category, but it is also possible to create a category
                    // in other, more simple ways, shown below.
                    _note = new CustomPresenceCategory("note", String.Format(_noteXml, _noteValue));

                    // The PresenceState class has several static properties
                    // and methods which will provide standard states such as
                    // online, busy, and on-the-phone, for example.
                    _userState = PresenceState.UserBusy;

                    // It is possible to create and publish state with a
                    // custom availablity string, shown below. "In a call" will
                    // be shown in Microsoft Lync.
                    LocalizedString localizedCallString = new LocalizedString(
                        "In a call" /* The string to be displayed. */);

                    // Create a PresenceActivity indicating the
                    // "In a call" state.
                    PresenceActivity inACall = new PresenceActivity(
                        localizedCallString);

                    // Set the Availability of the "In a call" state to Busy.
                    inACall.SetAvailabilityRange((int)PresenceAvailability.Busy,
                                                 (int)PresenceAvailability.IdleBusy);

                    // Microsoft Lync will also show the Busy presence icon.
                    _phoneState = new PresenceState(
                        (int)PresenceAvailability.Busy,
                        inACall,
                        PhoneCallType.Voip,
                        "phone uri");

                    // Machine or Endpoint states must always be published to
                    // indicate the endpoint is actually online, otherwise it is
                    // assumed the endpoint is offline, and no presence
                    // published from that endpoint will be displayed.
                    _machineState = PresenceState.EndpointOnline;

                    // It is also possible to create presence categories such
                    // as ContactCard, Note, PresenceState, and Services with
                    // their constructors.
                    // Here we create a ContactCard and change the title.
                    _contactCard = new ContactCard(3);
                    LocalizedString localizedTitleString = new LocalizedString(
                        "The Boss" /* The title string to be displayed. */);
                    _contactCard.JobTitle = localizedTitleString.Value;

                    // Publish a photo
                    // If the supplied value for photo is null or empty, then set value of IsAllowedToShowPhoto to false
                    _contactCard.IsAllowedToShowPhoto = true;
                    string photoUri = UCMASampleHelper.PromptUser("Please enter a Photo Uri in the form of http://mysite/photo1.jpg", "PhotoURI1");
                    if (String.IsNullOrEmpty(photoUri))
                    {
                        photoUri = null;
                        _contactCard.IsAllowedToShowPhoto = false;
                    }
                    _contactCard.PhotoUri = photoUri;

                    // Publish all presence categories with new values.
                    _localOwnerPresence.BeginPublishPresence(
                        new PresenceCategory[]
                    {
                        _userState,
                        _phoneState,
                        _machineState,
                        _note,
                        _contactCard
                    },
                        PublishPresenceCompleted, /* async callback when publishing operation completes. */
                        publishFlag /* value TRUE indicates that presence to be published with new values. */);
                }
                else
                {
                    // Delete all presence categories.
                    _localOwnerPresence.BeginDeletePresence(
                        new PresenceCategory[]
                    {
                        _userState,
                        _phoneState,
                        _machineState,
                        _note,
                        _contactCard
                    },
                        PublishPresenceCompleted,
                        publishFlag /* value FALSE indicates that presence reverted to original values. */);
                }
            }
            catch (PublishSubscribeException pse)
            {
                // PublishSubscribeException is thrown when there were
                // exceptions during this presence operation such as badly
                // formed sip request, duplicate publications in the same
                // request etc.
                // TODO (Left to the reader): Include exception handling code
                // here.
                Console.WriteLine(pse.ToString());
            }
            catch (RealTimeException rte)
            {
                // RealTimeException is thrown when SIP Transport, SIP
                // Authentication, and credential-related errors are
                // encountered.
                // TODO (Left to the reader): Include exception handling code
                // here.
                Console.WriteLine(rte.ToString());
            }
        }
Пример #17
0
		public void InitialiseFromElement(DOMElement e, StateStub[] controllerStateStore)
		{
			Guid = e.Attributes.GetNamedItem("roomGuid").Value;
			Name = e.Attributes.GetNamedItem("roomName").Value;
			Url = e.Attributes.GetNamedItem("roomUrl").Value;
			Pinable = bool.Parse(e.Attributes.GetNamedItem("roomPinable").Value);
			pinned = bool.Parse(e.Attributes.GetNamedItem("roomPinned").Value);
			starred = bool.Parse(e.Attributes.GetNamedItem("roomStarred").Value);
			Starrable = bool.Parse(e.Attributes.GetNamedItem("roomStarrable").Value);
			isStarredByDefault = bool.Parse(e.Attributes.GetNamedItem("roomIsStarredByDefault").Value);
			ReadOnly = bool.Parse(e.Attributes.GetNamedItem("roomReadOnly").Value);
			IsPhotoChatRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsPhotoChatRoom").Value);
			IsPrivateChatRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsPrivateChatRoom").Value);
			IsNewPhotoAlertsRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsNewPhotoAlertsRoom").Value);
			Presence = (PresenceState)int.ParseInvariant(e.Attributes.GetNamedItem("roomPresence").Value);

			Icon = e.Attributes.GetNamedItem("roomIcon").Value;
			tokenDateTimeTicks = e.Attributes.GetNamedItem("roomTokenDateTimeTicks").Value;
			token = e.Attributes.GetNamedItem("roomToken").Value;
			hasArchive = bool.Parse(e.Attributes.GetNamedItem("roomHasArchive").Value);

			hiddenFromRoomList = bool.Parse(e.Attributes.GetNamedItem("roomHiddenFromRoomList").Value);
			isStreamRoom = bool.Parse(e.Attributes.GetNamedItem("roomisStreamRoom").Value);

			state = new StateStub();
			state.Initialise(
				Guid,
				bool.Parse(e.Attributes.GetNamedItem("roomSelected").Value),
				bool.Parse(e.Attributes.GetNamedItem("roomGuest").Value), 
				int.ParseInvariant(e.Attributes.GetNamedItem("roomNewMessages").Value), 
				int.ParseInvariant(e.Attributes.GetNamedItem("roomTotalMessages").Value), 
				e.Attributes.GetNamedItem("roomLatestItem").Value, 
				e.Attributes.GetNamedItem("roomLatestItemSeen").Value,
				e.Attributes.GetNamedItem("roomLatestItemOld").Value,
				int.ParseInvariant(e.Attributes.GetNamedItem("roomListOrder").Value),
				tokenDateTimeTicks,
				token);

			addToStateStoreIfNotAlreadyThere(controllerStateStore, state);

			stub = new RoomStub(
				Parent.ClientID, 
				Guid, 
				Name, 
				Url,
				Pinned,
				Starred,
				isStarredByDefault,
				Pinable,
				Starrable,
				Selected,
				Guest, 
				NewMessages, 
				TotalMessages, 
				LatestItem, 
				LatestItemSeen, 
				LatestItemOld,
				ReadOnly,
				state.listOrder,
				IsPhotoChatRoom,
				IsPrivateChatRoom,
				IsNewPhotoAlertsRoom,
				Presence,
				Icon,
				tokenDateTimeTicks,
				token,
				hasArchive,
				hiddenFromRoomList,
				isStreamRoom);
			
			html = new RoomHtml(stub, LoggedIn);

			InitialiseElements("");

			genericInitialise();
		}
Пример #18
0
        private static void UpdatePresence()
        {
            m_UpdatePresenceTimer -= Time.unscaledDeltaTime;
            if (m_UpdatePresenceTimer > 0.0f)
            {
                return;
            }
            m_UpdatePresenceTimer = m_UpdatePresenceDelaySeconds;

            PresenceState state  = PresenceState.NUM;
            bool          paused = false;
            LevelInfo     level  = null;

            if (GameManager.m_game_state == GameManager.GameState.NONE)
            {
                state = PresenceState.Starting;
            }
            else if ((GameManager.m_game_state == GameManager.GameState.MENU) && !MenuManager.m_game_paused)
            {
                state = (MenuManager.m_menu_state == MenuState.MP_PRE_MATCH_MENU) ? PresenceState.WaitingForMatch : PresenceState.Menus;
            }
            else
            {
#if !UNITY_XBOXONE
                //Playing something
                paused = MenuManager.m_game_paused;
                level  = GameplayManager.Level;
#endif

                if (GameplayManager.Level.Mission.Type == MissionType.TRAINING)
                {
                    state = PresenceState.Training;
                }
                else if (NetworkManager.IsMultiplayerSceneLoading() || NetworkManager.IsMultiplayerSceneLoaded())
                {
                    state  = PresenceState.Multiplayer;
                    paused = false;
                }
                else if (GameplayManager.IsChallengeMode)
                {
                    state = PresenceState.Challenge;
                }
                else
                {
                    state = PresenceState.Mission;
                }
            }

            Assert.True(state != PresenceState.NUM);

            if ((state == m_prev_state) && (paused == m_prev_paused) && (level == m_prev_level))
            {
                return;
            }
            Debug.Log("Presence: " + state + " " + paused + " " + ((level == null) ? "" : level.DisplayName));

            m_prev_state  = state;
            m_prev_paused = paused;
            m_prev_level  = level;

#if UNITY_XBOXONE
#if !UNITY_EDITOR
            XboxOneRichPresence.SetPresence(state, paused);
#endif
#elif UNITY_PS4
            PS4Manager.SetPresence(state, paused, level);
#else
            if (CloudProvider == CloudProviders.Steam)
            {
                Steam.SetPresence(state, paused, level);
            }
#if !UNITY_STANDALONE_LINUX
            else if (CloudProvider == CloudProviders.Galaxy)
            {
                GogGalaxyManager.SetPresence(state, paused, level);
            }
#endif
#endif
        }
Пример #19
0
		public void InitialiseFromStub(RoomStub roomStub, DOMElement roomList, StateStub[] controllerStateStore)
		{
			stub = roomStub;

			Guid = stub.guid;
			Name = stub.name;
			Url = stub.url;
			Pinable = stub.pinable;
			pinned = stub.pinned;
			starred = stub.starred;
			Starrable = stub.starrable;
			isStarredByDefault = stub.isStarredByDefault;
			ReadOnly = stub.readOnly;
			IsPhotoChatRoom = stub.isPhotoChatRoom;
			IsPrivateChatRoom = stub.isPrivateChatRoom;
			IsNewPhotoAlertsRoom = stub.isNewPhotoAlertsRoom;
			Presence = stub.presence;
			tokenDateTimeTicks = stub.tokenDateTimeTicks;
			token = stub.token;
			hasArchive = stub.hasArchive;


			state = new StateStub();
			state.Initialise(
				stub.guid, 
				stub.selected,
				stub.guest,
				stub.newMessages,
				stub.totalMessages,
				stub.latestItem,
				stub.latestItemSeen,
				stub.latestItemOld,
				stub.listOrder,
				stub.tokenDateTimeTicks,
				stub.token);

			addToStateStoreIfNotAlreadyThere(controllerStateStore, state);

			html = new RoomHtml(stub, LoggedIn);

			string outerClientID = roomStub.parentClientID + "_Room_" + Guid + "_Outer";
			DOMElement newNode = Document.CreateElement("span");
			newNode.ID = outerClientID;
			newNode.InnerHTML = html.ToHtml();
			roomList.AppendChild(newNode.FirstChild);

			InitialiseElements(outerClientID);

			genericInitialise();
		}
Пример #20
0
 void Awake()
 {
     lastUpdate = Time.time;
     state      = new IdlingState(Utils.GetEpochTime(), GameScenes.LOADING);
 }