Beispiel #1
0
        public async Task QuerySelfPresenceAsync()
        {
            QueryPresenceRequest request = new QueryPresenceRequest()
            {
                request_header = RequestHeaderBody,
                participant_id = new List <ParticipantId>()
                {
                    new ParticipantId()
                    {
                        chat_id = CurrentUser.id.chat_id, gaia_id = CurrentUser.id.gaia_id
                    }
                },
                field_mask = Enum.GetValues(typeof(FieldMask)).Cast <FieldMask>().ToList()
            };

            using (HttpResponseMessage message = await _client.PostProtoJson("presence/querypresence", _api_key, request))
            {
                QueryPresenceResponse response = await message.Content.ReadAsProtoJson <QueryPresenceResponse>();

                foreach (var presence in response.presence_result)
                {
                    CurrentUser.presence = presence.presence;
                }
            }
        }
Beispiel #2
0
        public async Task QueryPresencesAsync()
        {
            QueryPresenceRequest request = new QueryPresenceRequest()
            {
                request_header = RequestHeaderBody,
                participant_id = _contacts.Keys.Select(c => new ParticipantId()
                {
                    chat_id = c, gaia_id = c
                }).ToList(),
                field_mask = Enum.GetValues(typeof(FieldMask)).Cast <FieldMask>().ToList()
            };

            using (HttpResponseMessage message = await _client.PostProtoJson("presence/querypresence", _api_key, request))
            {
                QueryPresenceResponse response = await message.Content.ReadAsProtoJson <QueryPresenceResponse>();

                response.presence_result.Where(c => _contacts.ContainsKey(c.user_id.gaia_id)).ToList().ForEach((p) =>
                {
                    _contacts[p.user_id.gaia_id].presence = p.presence;
                    if (OnPresenceChanged != null)
                    {
                        OnPresenceChanged(this, _contacts[p.user_id.gaia_id]);
                    }
                });
            }
        }
Beispiel #3
0
        public async Task QueryPresencesAsync()
        {
            QueryPresenceRequest request = new QueryPresenceRequest()
            {
                request_header = RequestHeaderBody,
                participant_id = _contacts.Keys.Select(c => new ParticipantId()
                {
                    chat_id = c, gaia_id = c
                }).ToList(),
                field_mask = Enum.GetValues(typeof(FieldMask)).Cast <FieldMask>().ToList()
            };

            using (HttpResponseMessage message = await _client.PostProtoJson("presence/querypresence", _api_key, request))
            {
                QueryPresenceResponse response = await message.Content.ReadAsProtoJson <QueryPresenceResponse>();

                foreach (var presence in response.presence_result)
                {
                    if (_contacts.ContainsKey(presence.user_id.gaia_id))
                    {
                        setPresence(_contacts[presence.user_id.gaia_id], presence.presence);
                    }
                }
            }
        }
Beispiel #4
0
        public void QueryPresences()
        {
            QueryPresenceRequest request = new QueryPresenceRequest()
            {
                request_header = RequestHeaderBody,
                participant_id = this._contact_ids.Select(c => new ParticipantId()
                {
                    chat_id = c
                }).ToList(),
                field_mask = new List <FieldMask>()
                {
                    FieldMask.FIELD_MASK_AVAILABLE, FieldMask.FIELD_MASK_DEVICE, FieldMask.FIELD_MASK_REACHABLE
                }
            };

            HttpResponseMessage message = _client.PostProtoJson(_api_key, "presence/querypresence", request);

            if (PresenceInformationReceived != null)
            {
                QueryPresenceResponse response = message.Content.ReadAsProtoJson <QueryPresenceResponse>();

                foreach (var presence in response.presence_result)
                {
                    PresenceInformationReceived(this, presence);
                }
            }
        }
Beispiel #5
0
        public void QuerySelfPresence()
        {
            QueryPresenceRequest request = new QueryPresenceRequest()
            {
                request_header = RequestHeaderBody,
                participant_id = new List <ParticipantId>()
                {
                    new ParticipantId()
                    {
                        chat_id = CurrentUser.Id, gaia_id = CurrentUser.Id
                    }
                },
                field_mask = Enum.GetValues(typeof(FieldMask)).Cast <FieldMask>().ToList()
            };

            using (HttpResponseMessage message = _client.PostProtoJson("presence/querypresence", request))
            {
                QueryPresenceResponse response = message.Content.ReadAsProtoJson <QueryPresenceResponse>();

                foreach (var presence in response.presence_result)
                {
                    setPresence(CurrentUser, presence.presence);
                }
            }
        }
Beispiel #6
0
        public void QueryPresences()
        {
            QueryPresenceRequest request = new QueryPresenceRequest()
            {
                request_header = RequestHeaderBody,
                participant_id = this._contacts.Keys.Select(c => new ParticipantId()
                {
                    chat_id = c
                }).ToList(),
                field_mask = Enum.GetValues(typeof(FieldMask)).Cast <FieldMask>().ToList()
            };

            HttpResponseMessage   message  = _client.PostProtoJson("presence/querypresence", request);
            QueryPresenceResponse response = message.Content.ReadAsProtoJson <QueryPresenceResponse>();

            foreach (var presence in response.presence_result)
            {
                _contacts[presence.user_id.chat_id].SetPresence(presence.presence);
            }
        }