コード例 #1
0
        private static void FillReportToInfo(IUser user, string propertyName, Control parent, string labelID)
        {
            HyperLink    lbl      = (HyperLink)parent.FindControl(labelID);
            UserPresence presence = (UserPresence)parent.FindControl("reportTouserPresence");

            if (lbl != null)
            {
                UserReportInfo reportInfo = GetUserProperty(user, "ReportTo", (UserReportInfo)null);

                if (reportInfo != null)
                {
                    presence.UserID          = reportInfo.ReportTo.ID;
                    presence.UserDisplayName = reportInfo.ReportTo.DisplayName;

                    lbl.Text        = HttpUtility.HtmlEncode(reportInfo.ReportTo.DisplayName);
                    lbl.NavigateUrl = "editUserReportToInfo.aspx?userID=" + HttpUtility.UrlEncode(reportInfo.User.ID);
                }
                else
                {
                    lbl.Style[HtmlTextWriterStyle.PaddingLeft] = "16px";
                    lbl.Text        = HttpUtility.HtmlEncode("增加");
                    lbl.NavigateUrl = "editUserReportToInfo.aspx?userID=" + HttpUtility.UrlEncode(user.ID);
                }
            }
        }
コード例 #2
0
ファイル: Eye.cs プロジェクト: jjoonnii/Running-Eye
 // Use this for initialization
 void Start()
 {
     cube  = GameObject.Find("Cube");
     floor = GameObject.Find("Floor");
     gaze  = cube.GetComponent <GazeAware>();
     up    = TobiiAPI.GetUserPresence();
 }
コード例 #3
0
        public void Instantiates_With_The_Given_Data(string username, UserPresence status, bool privileged)
        {
            var r = new UserStatusResponse(username, status, privileged);

            Assert.Equal(username, r.Username);
            Assert.Equal(status, r.Status);
            Assert.Equal(privileged, r.IsPrivileged);
        }
コード例 #4
0
        public void PatchUserIdPresencesSourceIdTest()
        {
            // TODO: add unit test for the method 'PatchUserIdPresencesSourceId'
            string       userId   = null; // TODO: replace null with proper value
            string       sourceId = null; // TODO: replace null with proper value
            UserPresence body     = null; // TODO: replace null with proper value
            var          response = instance.PatchUserIdPresencesSourceId(userId, sourceId, body);

            Assert.IsInstanceOf <UserPresence> (response, "response is UserPresence");
        }
コード例 #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = UserPresence.GetHashCode();
         hashCode = (hashCode * 397) ^ Counter;
         hashCode = (hashCode * 397) ^ (Signature != null ? Signature.GetHashCode() : 0);
         return(hashCode);
     }
 }
コード例 #6
0
 /// <summary>
 /// Set the lerp color
 /// </summary>
 void Start()
 {
     _gazeAwareComponent = GetComponent <GazeAware>();
     _meshRenderer       = GetComponent <MeshRenderer>();
     _lerpColor          = _meshRenderer.material.color;
     _deselectionColor   = new Color(1f, 1f, 1f, 0.2f);
     _userPresence       = TobiiAPI.GetUserPresence();
     //  _deselectionColorText = new Color(1f, 1f, 1f, 0.4f);
     //  textcolor = new Color(0f,0f,0f,1f);
 }
コード例 #7
0
ファイル: UserData.cs プロジェクト: jpdillingham/Soulseek.NET
 /// <summary>
 ///     Initializes a new instance of the <see cref="UserData"/> class.
 /// </summary>
 /// <param name="username">The username of the user.</param>
 /// <param name="status">The status of the user.</param>
 /// <param name="averageSpeed">The average upload speed of the user.</param>
 /// <param name="uploadCount">The number of uploads tracked by the server for this user.</param>
 /// <param name="fileCount">The number of files shared by the user.</param>
 /// <param name="directoryCount">The number of directories shared by the user.</param>
 /// <param name="countryCode">The user's country code.</param>
 /// <param name="slotsFree">The number of the user's free download slots, if provided.</param>
 public UserData(string username, UserPresence status, int averageSpeed, long uploadCount, int fileCount, int directoryCount, string countryCode, int?slotsFree = null)
 {
     Username       = username;
     Status         = status;
     AverageSpeed   = averageSpeed;
     UploadCount    = uploadCount;
     FileCount      = fileCount;
     DirectoryCount = directoryCount;
     SlotsFree      = slotsFree;
     CountryCode    = countryCode;
 }
コード例 #8
0
        public void SetOnlineStatus_Constructs_The_Correct_Message(UserPresence status)
        {
            var a   = new SetOnlineStatusCommand(status);
            var msg = a.ToByteArray();

            var reader = new MessageReader <MessageCode.Server>(msg);
            var code   = reader.ReadCode();

            Assert.Equal(MessageCode.Server.SetOnlineStatus, code);
            Assert.Equal((int)status, reader.ReadInteger());
        }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        UserPresence userPresence = TobiiAPI.GetUserPresence();

        if (userPresence.IsUserPresent())
        {
            lookatPoint = camera.ScreenToWorldPoint(TobiiAPI.GetGazePoint().Screen);
            var moveVector = new Vector3(lookatPoint.x - moveObject.transform.position.x, lookatPoint.y - moveObject.transform.position.y, 0).normalized;
            moveObject.transform.Translate(moveVector * Time.deltaTime * speed);
        }
    }
        public Task DeleteAsync(UserPresence userPresence)
        {
            var foundUserPresence = _context.UserPresences.Find(userPresence.User.Id);

            if (foundUserPresence != null)
            {
                _context.UserPresences.Remove(foundUserPresence);
                _context.SaveChanges();
            }
            return(Task.FromResult(0));
        }
        public Task UpdateAsync(UserPresence userPresence)
        {
            var foundUserPresence = _context.UserPresences.Find(userPresence.User.Id);

            if (foundUserPresence != null)
            {
                foundUserPresence.State       = userPresence.Data.State;
                foundUserPresence.IsInvitable = userPresence.Data.IsInvitable;
                _context.SaveChanges();
            }
            return(Task.FromResult(0));
        }
        public Task CreateAsync(UserPresence userPresence)
        {
            var newUserPresence = new Model.UserPresence
            {
                UserId      = userPresence.User.Id,
                State       = userPresence.Data.State,
                IsInvitable = userPresence.Data.IsInvitable
            };

            _context.UserPresences.Add(newUserPresence);
            return(_context.SaveChangesAsync());
        }
コード例 #13
0
ファイル: Eye.cs プロジェクト: jjoonnii/Running-Eye
 // Update is called once per frame
 void Update()
 {
     up = TobiiAPI.GetUserPresence();
     if (physics == true)
     {
         if (up == UserPresence.Present)
         {
             hp = TobiiAPI.GetHeadPose();
             if (hp.Rotation.eulerAngles.y > 180)
             {
                 if (hp.Rotation.eulerAngles.y < 330)
                 {
                     rb.AddForce((360 - hp.Rotation.eulerAngles.y) * (-1) / 5, 0, 0, ForceMode.Force);
                 }
             }
             if (hp.Rotation.eulerAngles.y < 180)
             {
                 if (hp.Rotation.eulerAngles.y > 20)
                 {
                     rb.AddForce(hp.Rotation.eulerAngles.y / 5, 0, 0, ForceMode.Force);
                 }
             }
         }
     }
     if (floorPresent == true)
     {
         if (up == UserPresence.NotPresent)
         {
             floor.active = false;
             floorPresent = false;
         }
     }
     if (gaze.HasGazeFocus)
     {
         if (physics == false)
         {
             if (dwellTime == 0)
             {
                 dwellTime = Time.time;
             }
             if (Time.time - dwellTime >= 0.4)
             {
                 cube.AddComponent <Rigidbody>();
                 rb      = cube.GetComponent <Rigidbody>();
                 physics = true;
             }
         }
     }
     if (!gaze.HasGazeFocus)
     {
         dwellTime = 0;
     }
 }
コード例 #14
0
        protected void showPresenceWithScript_Click(object sender, EventArgs e)
        {
            StringBuilder strB = new StringBuilder();

            int index = 0;

            foreach (IOguObject obj in userInput.SelectedOuUserData)
            {
                strB.Append(UserPresence.GetUsersPresenceHtml(obj.ID, obj.DisplayName, "up_" + index, true, false, true, StatusImageType.Ball, ""));
                index++;
            }

            usersPresenceScriptResultContainer.InnerHtml = strB.ToString();
        }
コード例 #15
0
        public void Parse_Returns_Expected_Data(string username, UserPresence status, bool privileged)
        {
            var msg = new MessageBuilder()
                      .WriteCode(MessageCode.Server.GetStatus)
                      .WriteString(username)
                      .WriteInteger((int)status)
                      .WriteByte((byte)(privileged ? 1 : 0))
                      .Build();

            var r = UserStatusResponse.FromByteArray(msg);

            Assert.Equal(username, r.Username);
            Assert.Equal(status, r.Status);
            Assert.Equal(privileged, r.IsPrivileged);
        }
コード例 #16
0
        protected void showPresenceBtn_Click(object sender, EventArgs e)
        {
            usersPresenceContainer.Controls.Clear();
            HtmlGenericControl div = new HtmlGenericControl("div");

            foreach (IOguObject obj in userInput.SelectedOuUserData)
            {
                UserPresence presence = new UserPresence(); //初始化用户状态控件

                presence.UserID          = obj.ID;          //所需要显示的用户ID
                presence.UserDisplayName = obj.DisplayName; //用户名称
                presence.StatusImage     = StatusImageType.ShortBar;

                div.Controls.Add(presence);                  //放入到显示区域
            }
            usersPresenceContainer.Controls.Add(div);
        }
コード例 #17
0
        public async Task SetStatusAsync_Sends_Expected_Status(UserPresence status)
        {
            var conn = new Mock <IMessageConnection>();

            conn.Setup(m => m.State)
            .Returns(ConnectionState.Connected);

            using (var s = new SoulseekClient(serverConnection: conn.Object))
            {
                s.SetProperty("State", SoulseekClientStates.Connected | SoulseekClientStates.LoggedIn);

                var ex = await Record.ExceptionAsync(() => s.SetStatusAsync(status));

                Assert.Null(ex);
            }

            conn.Verify(m => m.WriteAsync(It.Is <SetOnlineStatusCommand>(s => s.Status == status), It.IsAny <CancellationToken>()), Times.Once);
        }
コード例 #18
0
ファイル: UsersHub.cs プロジェクト: yangwugui/CommunityServer
        private void RemoveOnlineUser()
        {
            try
            {
                var isLostUser = false;

                InitDictionary(onlineUsers, CurrentTenantId);
                onlineUsers[CurrentTenantId]
                .AddOrUpdate(CurrentUserId,
                             user =>
                {
                    isLostUser = true;
                    return(null);
                },
                             (user, presence) =>
                {
                    if (presence == null)
                    {
                        presence = new UserPresence(DateTime.UtcNow);
                    }
                    if (presence.Counter == 1)
                    {
                        presence.OfflinePretender = true;
                        SetOfflinePretenderTimer();
                    }
                    presence.Counter--;

                    return(presence);
                });

                if (isLostUser)
                {
                    UserPresence p;
                    onlineUsers[CurrentTenantId].TryRemove(CurrentUserId, out p);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
コード例 #19
0
        public void GetUserPresence()
        {
            Task.Run(async() =>
            {
                User user = await User.FromID(TestConstants.TestUserId);

                Assert.IsNotNull(user);

                UserPresence p = await user.GetUserPresence();

                Assert.IsNotNull(p);

                Console.WriteLine("IsOnline: {0}", p.IsOnline);

                Console.WriteLine("GameId: {0}", p.GameId);
                Console.WriteLine("LastLocation: {0}", p.LastLocation);
                Console.WriteLine("LastOnline: {0}", p.LastOnline);
                Console.WriteLine("LocationType: {0}", p.LocationType);
                Console.WriteLine("PlaceId: {0}", p.PlaceId);
                Console.WriteLine("PlaceId: {0}", p.VisitorId);
            }).Wait(TestConstants.MaxMilisecondTimeout);
        }
コード例 #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                HtmlGenericControl div = new HtmlGenericControl("div");

                UserPresence presence0 = new UserPresence();                                                                         //初始化用户状态控件

                presence0.UserID = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "changdm")[0].ID; // "22c3b351-a713-49f2-8f06-6b888a280fff";

                presence0.UserDisplayName = "常冬梅";

                //presence0.AccountDisabled=true;

                UserPresence presence = new UserPresence(); //初始化用户状态控件

                presence.UserID              = "22c3b351-a713-49f2-8f06-6b888a280fff";
                presence.StatusImage         = StatusImageType.ShortBar;
                presence.ShowUserIcon        = true;
                presence.UserIconUrl         = "cdm.png";
                presence.ShowUserDisplayName = true;
                presence.UserDisplayName     = "常冬梅";
                presence.AccountDisabled     = true;

                UserPresence presence1 = new UserPresence(); //初始化用户状态控件

                presence1.UserID          = "22c3b351-a713-49f2-8f06-6b888a280fff";
                presence1.StatusImage     = StatusImageType.LongBar;
                presence1.ShowUserIcon    = true;
                presence1.UserIconUrl     = "cdm.png";
                presence1.UserDisplayName = "cdm";
                presence1.AccountDisabled = true;

                div.Controls.Add(presence0);
                div.Controls.Add(presence);
                div.Controls.Add(presence1);
                usersPresenceContainer.Controls.Add(div);
            }
        }
コード例 #21
0
    private void Update()
    {
        //Pauses the level
        UserPresence userPresence = TobiiAPI.GetUserPresence();
        HeadPose     headPose     = TobiiAPI.GetHeadPose();

        if (!m_levelManager.paused)
        {
            if (Input.GetButtonDown("Pause") || (GazeManager.TobiiConnected && (userPresence != UserPresence.Present || !headPose.IsValid)))
            {
                m_levelManager.TooglePause();
                Show();
                m_active = true;
            }
        }
        //Resume
        else if (m_active && Input.GetButtonDown("Pause"))
        {
            m_levelManager.TooglePause();
            Hide();
            m_active = false;
        }
    }
コード例 #22
0
        public void UpdateStatus(string status)
        {
            try
            {
                // Get presences
                int pageNumber = 1;
                int pageSize   = 100;
                OrganizationPresenceEntityListing presences = presenceApi.GetPresencedefinitions(pageNumber, pageSize);


                UserPresence body = new UserPresence();
                body.Primary            = true;
                body.Source             = "PURECLOUD";
                body.Message            = "modification via API";
                body.PresenceDefinition = new PresenceDefinition();
                body.Name = "test API";

                // Find status presences in the org
                foreach (var pres in presences.Entities)
                {
                    if (pres.SystemPresence.Equals(status) && pres.Primary.Equals(true))
                    {
                        body.PresenceDefinition.Id = pres.Id;
                    }
                }


                var result = presenceApi.PatchUserPresence(_agentId, body.PresenceDefinition.Id, body);
                AddLog("UpdateStatus: " + status + " for agent " + _agentId);
            }
            catch (Exception ex)
            {
                AddLog($"Error in UpdateStatusAvailable: {ex.Message}");
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #23
0
        public async Task GetUserStatusAsync_Returns_Expected_Info(string username, UserPresence presence, bool privileged)
        {
            var result = new UserStatusResponse(username, presence, privileged);

            var waiter = new Mock <IWaiter>();

            waiter.Setup(m => m.Wait <UserStatusResponse>(It.IsAny <WaitKey>(), null, It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(result));

            var serverConn = new Mock <IMessageConnection>();

            serverConn.Setup(m => m.WriteAsync(It.IsAny <IOutgoingMessage>(), It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask);

            using (var s = new SoulseekClient(waiter: waiter.Object, serverConnection: serverConn.Object))
            {
                s.SetProperty("State", SoulseekClientStates.Connected | SoulseekClientStates.LoggedIn);

                var status = await s.GetUserStatusAsync(username);

                Assert.Equal(result.Status, status.Presence);
                Assert.Equal(result.IsPrivileged, status.IsPrivileged);
            }
        }
コード例 #24
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="UserStatus"/> class.
 /// </summary>
 /// <param name="presence">The user's network presence.</param>
 /// <param name="isPrivileged">A value indicating whether the user is privileged.</param>
 public UserStatus(UserPresence presence, bool isPrivileged)
 {
     Presence     = presence;
     IsPrivileged = isPrivileged;
 }
コード例 #25
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="UserStatus"/> class.
 /// </summary>
 /// <param name="username">The username of the user.</param>
 /// <param name="presence">The user's network presence.</param>
 /// <param name="isPrivileged">A value indicating whether the user is privileged.</param>
 public UserStatus(string username, UserPresence presence, bool isPrivileged)
 {
     Username     = username;
     Presence     = presence;
     IsPrivileged = isPrivileged;
 }
コード例 #26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lstParticipant"></param>
 public async Task GetPresenceAsync()
 {
     this.PresenceStatus = await Task.Factory.StartNew(() => UserPresence.GetUserPresence(NeeoUtility.ConvertToJid(_userID)));
 }
コード例 #27
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lstParticipant"></param>
 public void GetPresence()
 {
     this.PresenceStatus = UserPresence.GetUserPresence(NeeoUtility.ConvertToJid(_userID));
 }
コード例 #28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lstParticipant"></param>
 public static Presence GetPresence(string userID)
 {
     return(UserPresence.GetUserPresence(NeeoUtility.ConvertToJid(userID)));
 }
コード例 #29
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="UserStatusResponse"/> class.
 /// </summary>
 /// <param name="username">The username of the peer.</param>
 /// <param name="status">The status of the peer.</param>
 /// <param name="isPrivileged">A value indicating whether the peer is privileged.</param>
 public UserStatusResponse(string username, UserPresence status, bool isPrivileged)
 {
     Username     = username;
     Status       = status;
     IsPrivileged = isPrivileged;
 }
コード例 #30
0
        public async Task GetUserStatusAsync_Throws_OperationCanceledException_On_Cancellation(string username, UserPresence status, bool privileged)
        {
            var result = new UserStatusResponse(username, status, privileged);

            var waiter = new Mock <IWaiter>();

            waiter.Setup(m => m.Wait <UserStatusResponse>(It.IsAny <WaitKey>(), null, It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(result));

            var serverConn = new Mock <IMessageConnection>();

            serverConn.Setup(m => m.WriteAsync(It.IsAny <IOutgoingMessage>(), It.IsAny <CancellationToken>()))
            .Throws(new OperationCanceledException());

            using (var s = new SoulseekClient(waiter: waiter.Object, serverConnection: serverConn.Object))
            {
                s.SetProperty("State", SoulseekClientStates.Connected | SoulseekClientStates.LoggedIn);

                var ex = await Record.ExceptionAsync(() => s.GetUserStatusAsync(username));

                Assert.NotNull(ex);
                Assert.IsType <OperationCanceledException>(ex);
            }
        }