コード例 #1
0
ファイル: HereNowOperation.cs プロジェクト: umersain/c-sharp
        internal async Task <PNResult <PNHereNowResult> > HereNow(string[] channels, string[] channelGroups, bool showUUIDList, bool includeUserState, Dictionary <string, object> externalQueryParam)
        {
            PNResult <PNHereNowResult> ret = new PNResult <PNHereNowResult>();

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null) ? PubnubInstance.InstanceId : "");

            Uri request = urlBuilder.BuildHereNowRequest("GET", "", channels, channelGroups, showUUIDList, includeUserState, externalQueryParam);

            RequestState <PNHereNowResult> requestState = new RequestState <PNHereNowResult>();

            requestState.Channels          = channels;
            requestState.ChannelGroups     = channelGroups;
            requestState.ResponseType      = PNOperationType.PNHereNowOperation;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            Tuple <string, PNStatus> JsonAndStatusTuple = await UrlProcessRequest(request, requestState, false).ConfigureAwait(false);

            ret.Status = JsonAndStatusTuple.Item2;
            string json = JsonAndStatusTuple.Item1;

            if (!string.IsNullOrEmpty(json))
            {
                List <object>   resultList      = ProcessJsonResponse(requestState, json);
                ResponseBuilder responseBuilder = new ResponseBuilder(config, jsonLibrary, pubnubLog);
                PNHereNowResult responseResult  = responseBuilder.JsonToObject <PNHereNowResult>(resultList, true);
                if (responseResult != null)
                {
                    ret.Result = responseResult;
                }
            }

            return(ret);
        }
コード例 #2
0
ファイル: Example.cs プロジェクト: SaketSaumya/ARCHATv5
 void DisplayHereNowResult(PNHereNowResult result)
 {
     if (result.Channels != null)
     {
         foreach (KeyValuePair <string, PNHereNowChannelData> kvp in result.Channels)
         {
             Debug.Log("in HereNow channel: " + kvp.Key);
             if (kvp.Value != null)
             {
                 PNHereNowChannelData hereNowChannelData = kvp.Value as PNHereNowChannelData;
                 if (hereNowChannelData != null)
                 {
                     Debug.Log("in HereNow channelName: " + hereNowChannelData.ChannelName);
                     Display(string.Format("channelName: {0}", hereNowChannelData.ChannelName));
                     Debug.Log("in HereNow channel occupancy: " + hereNowChannelData.Occupancy.ToString());
                     Display(string.Format("channelName: {0}", hereNowChannelData.Occupancy));
                     List <PNHereNowOccupantData> hereNowOccupantData = hereNowChannelData.Occupants as List <PNHereNowOccupantData>;
                     if (hereNowOccupantData != null)
                     {
                         foreach (PNHereNowOccupantData pnHereNowOccupantData in hereNowOccupantData)
                         {
                             if (pnHereNowOccupantData.State != null)
                             {
                                 Debug.Log("in HereNow channel State: " + pnHereNowOccupantData.State.ToString());
                                 Display(string.Format("State: {0}", pnHereNowOccupantData.State.ToString()));
                             }
                             if (pnHereNowOccupantData.UUID != null)
                             {
                                 Debug.Log("in HereNow channel UUID: " + pnHereNowOccupantData.UUID.ToString());
                                 Display(string.Format("UUID: {0}", pnHereNowOccupantData.UUID.ToString()));
                             }
                         }
                     }
                     else
                     {
                         Debug.Log("in HereNow hereNowOccupantData null");
                     }
                 }
                 else
                 {
                     Debug.Log("in HereNow hereNowChannelData null");
                 }
             }
             else
             {
                 Debug.Log("in HereNow kvp null");
             }
         }
     }
     else
     {
         Debug.Log("in HereNow channels null");
     }
 }
コード例 #3
0
 void DisplayHereNowResult(PNHereNowResult result)
 {
     if (result.Channels != null)
     {
         foreach (KeyValuePair <string, PNHereNowChannelData> kvp in result.Channels)
         {
             Debug.Log("in HereNow channel: " + kvp.Key);
             if (kvp.Value != null)
             {
                 PNHereNowChannelData hereNowChannelData = kvp.Value as PNHereNowChannelData;
                 if (hereNowChannelData != null)
                 {
                     StringBuilder sb = new StringBuilder();
                     sb.Append("in HereNow channelName: " + hereNowChannelData.ChannelName);
                     Display(string.Format("channelName: {0}", hereNowChannelData.ChannelName));
                     sb.Append("in HereNow channel occupancy: " + hereNowChannelData.Occupancy.ToString());
                     Display(string.Format("channelName: {0}", hereNowChannelData.Occupancy));
                     List <PNHereNowOccupantData> hereNowOccupantData = hereNowChannelData.Occupants as List <PNHereNowOccupantData>;
                     if (hereNowOccupantData != null)
                     {
                         foreach (PNHereNowOccupantData pnHereNowOccupantData in hereNowOccupantData)
                         {
                             if (pnHereNowOccupantData.State != null)
                             {
                                 sb.Append("in HereNow channel State: " + pnHereNowOccupantData.State.ToString());
                                 Dictionary <string, object> state = pnHereNowOccupantData.State as Dictionary <string, object>;
                                 foreach (KeyValuePair <string, object> kvpState in state)
                                 {
                                     sb.Append(kvp.Key);
                                     sb.Append("=====>");
                                     sb.Append(kvp.Value.ToString());
                                 }
                                 Display(string.Format("State: {0}", pnHereNowOccupantData.State.ToString()));
                             }
                             if (pnHereNowOccupantData.UUID != null)
                             {
                                 sb.Append("in HereNow channel UUID: " + pnHereNowOccupantData.UUID.ToString());
                                 Display(string.Format("UUID: {0}", pnHereNowOccupantData.UUID.ToString()));
                             }
                         }
                     }
                     else
                     {
                         sb.Append("in HereNow hereNowOccupantData null");
                     }
                     Debug.Log(sb.ToString());
                 }
                 else
                 {
                     Debug.Log("in HereNow hereNowChannelData null");
                 }
             }
             else
             {
                 Debug.Log("in HereNow kvp null");
             }
         }
     }
     else
     {
         Debug.Log("in HereNow channels null");
     }
 }