Exemple #1
0
        public async Task QuerySelfPresenceAsync()
        {
            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 = await _client.PostProtoJson("presence/querypresence", _api_key, request))
            {
                QueryPresenceResponse response = await message.Content.ReadAsProtoJson<QueryPresenceResponse>();

                foreach (var presence in response.presence_result)
                    setPresence(CurrentUser, presence.presence);
            }
        }
Exemple #2
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);
            }
        }
Exemple #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);
            }

        }