public RemoveMessageActionsBuilder(PubNubUnity pn) { removeMessageActionsBuilder = new RemoveMessageActionsRequestBuilder(pn); }
public ListFilesRequestBuilder(PubNubUnity pn) : base(pn, PNOperationType.PNListFilesOperation) { ListFilesLimit = 100; }
public DeleteUserBuilder(PubNubUnity pn) { deleteUserBuilder = new DeleteUserRequestBuilder(pn); }
public static Uri BuildGetChannelsForChannelGroupRequest(string nameSpace, string groupName, bool limitToChannelGroupScopeOnly, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { bool groupNameAvailable = false; bool nameSpaceAvailable = false; // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("channel-registration"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); List <string> ns = Utility.CheckAndAddNameSpace(nameSpace); if (ns != null) { nameSpaceAvailable = true; url.AddRange(ns); } if (limitToChannelGroupScopeOnly) { url.Add("channel-group"); } else { if (!string.IsNullOrEmpty(groupName) && groupName.Trim().Length > 0) { groupNameAvailable = true; url.Add("channel-group"); url.Add(groupName); } if (!nameSpaceAvailable && !groupNameAvailable) { url.Add("namespace"); } else if (nameSpaceAvailable && !groupNameAvailable) { url.Add("channel-group"); } } return(BuildRestApiRequest <Uri>(url, PNOperationType.PNChannelsForGroupOperation, "", pnInstance, queryParams)); }
public static Uri BuildUnregisterDevicePushRequest(PNPushType pushType, string pushToken, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?type={0}", pushType.ToString().ToLowerInvariant()); // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("push"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("devices"); url.Add(pushToken); url.Add("remove"); return(BuildRestApiRequest <Uri>(url, PNOperationType.PNRemoveAllPushNotificationsOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public static Uri BuildPresenceHeartbeatRequest(string channels, string channelGroups, string channelsJsonState, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder presenceParamBuilder = new StringBuilder(); if (channelsJsonState != "{}" && channelsJsonState != "") { presenceParamBuilder.AppendFormat("&state={0}", Utility.EncodeUricomponent(channelsJsonState, PNOperationType.PNPresenceHeartbeatOperation, false, false)); } if (channelGroups != null && channelGroups.Length > 0) { presenceParamBuilder.AppendFormat("&channel-group={0}", Utility.EncodeUricomponent(channelGroups, PNOperationType.PNPresenceHeartbeatOperation, true, false)); } List <string> url = new List <string> (); url.Add("v2"); url.Add("presence"); url.Add("sub_key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("channel"); url.Add(string.IsNullOrEmpty(channels) ? "," : channels); url.Add("heartbeat"); return(BuildRestApiRequest <Uri> (url, PNOperationType.PNPresenceHeartbeatOperation, presenceParamBuilder.ToString(), pnInstance, queryParams)); }
public static Uri BuildAddChannelsToChannelGroupRequest(string[] channels, string nameSpace, string groupName, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { string parameters = string.Format("?add={0}", Utility.EncodeUricomponent(string.Join(",", channels), PNOperationType.PNAddChannelsToGroupOperation, true, false)); // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("channel-registration"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); List <string> ns = Utility.CheckAndAddNameSpace(nameSpace); if (ns != null) { url.AddRange(ns); } url.Add("channel-group"); url.Add(groupName); return(BuildRestApiRequest <Uri>(url, PNOperationType.PNAddChannelsToGroupOperation, parameters, pnInstance, queryParams)); }
public ManageMembersRequestBuilder(PubNubUnity pn) : base(pn, PNOperationType.PNManageMembersOperation) { }
public CreateSpaceBuilder(PubNubUnity pn) { createSpaceBuilder = new CreateSpaceRequestBuilder(pn); }
public TimeBuilder(PubNubUnity pn) { pubBuilder = new TimeRequestBuilder(pn); }
public GetSpacesBuilder(PubNubUnity pn) { getSpacesBuilder = new GetSpacesRequestBuilder(pn); }
public SetChannelMetadataBuilder(PubNubUnity pn) { setChannelMetadataRequestBuilder = new SetChannelMetadataRequestBuilder(pn); }
public AddChannelsToChannelGroupBuilder(PubNubUnity pn) { pubBuilder = new AddChannelsToChannelGroupRequestBuilder(pn); }
public GetMembershipsBuilder(PubNubUnity pn) { getMembershipsBuilder = new GetMembershipsRequestBuilder(pn); }
public static Uri BuildSetStateRequest(string channel, string channelGroup, string jsonUserState, string uuid, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder paramBuilder = new StringBuilder(); paramBuilder.AppendFormat("?state={0}", Utility.EncodeUricomponent(jsonUserState, PNOperationType.PNSetStateOperation, false, false)); if (!string.IsNullOrEmpty(channelGroup) && channelGroup.Trim().Length > 0) { paramBuilder.AppendFormat("&channel-group={0}", Utility.EncodeUricomponent(channelGroup, PNOperationType.PNSetStateOperation, true, false)); } List <string> url = new List <string> (); url.Add("v2"); url.Add("presence"); url.Add("sub_key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("channel"); url.Add(string.IsNullOrEmpty(channel) ? "," : channel); url.Add("uuid"); url.Add(uuid); url.Add("data"); return(BuildRestApiRequest <Uri> (url, PNOperationType.PNSetStateOperation, paramBuilder.ToString(), pnInstance, queryParams)); }
public static Uri BuildPublishRequest(string channel, string message, bool storeInHistory, string metadata, uint messageCounter, int ttl, bool usePost, bool repilicate, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("&seqn={0}", messageCounter.ToString()); parameterBuilder.Append((storeInHistory) ? "" : "&store=0"); if (ttl >= 0) { parameterBuilder.AppendFormat("&ttl={0}", ttl.ToString()); } if (!repilicate) { parameterBuilder.Append("&norep=true"); } if (!string.IsNullOrEmpty(metadata) || metadata.Equals("\"\"")) { parameterBuilder.AppendFormat("&meta={0}", Utility.EncodeUricomponent(metadata, PNOperationType.PNPublishOperation, false, false)); } // Generate String to Sign string signature = "0"; if (!string.IsNullOrEmpty(pnInstance.PNConfig.SecretKey) && (pnInstance.PNConfig.SecretKey.Length > 0)) { StringBuilder stringToSign = new StringBuilder(); stringToSign .Append(pnInstance.PNConfig.PublishKey) .Append('/') .Append(pnInstance.PNConfig.SubscribeKey) .Append('/') .Append(pnInstance.PNConfig.SecretKey) .Append('/') .Append(channel); if (!usePost) { stringToSign.Append('/'); stringToSign.Append(message); // 1 } // Sign Message PubnubCrypto pnCrypto = new PubnubCrypto(pnInstance.PNConfig.CipherKey, pnInstance.PNLog); signature = pnCrypto.ComputeHashRaw(stringToSign.ToString()); } // Build URL List <string> url = new List <string> (); url.Add("publish"); url.Add(pnInstance.PNConfig.PublishKey); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add(signature); url.Add(channel); url.Add("0"); if (!usePost) { url.Add(message); } return(BuildRestApiRequest <Uri> (url, PNOperationType.PNPublishOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public static Uri BuildGetStateRequest(string channel, string channelGroup, string uuid, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { string parameters = ""; if (!string.IsNullOrEmpty(channelGroup) && channelGroup.Trim().Length > 0) { parameters = string.Format("&channel-group={0}", Utility.EncodeUricomponent(channelGroup, PNOperationType.PNGetStateOperation, true, false)); } List <string> url = new List <string> (); url.Add("v2"); url.Add("presence"); url.Add("sub_key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("channel"); url.Add(string.IsNullOrEmpty(channel) ? "," : channel); url.Add("uuid"); url.Add(uuid); return(BuildRestApiRequest <Uri> (url, PNOperationType.PNGetStateOperation, parameters, pnInstance, queryParams)); }
public static Uri BuildDeleteMessagesRequest(string channel, long start, long end, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); if (start != -1) { parameterBuilder.AppendFormat("&start={0}", start.ToString().ToLowerInvariant()); } if (end != -1) { parameterBuilder.AppendFormat("&end={0}", end.ToString().ToLowerInvariant()); } long timeStamp = Utility.TranslateDateTimeToSeconds(DateTime.UtcNow); parameterBuilder.AppendFormat("×tamp={0}", timeStamp.ToString()); List <string> url = new List <string> (); url.Add("v3"); url.Add("history"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("channel"); url.Add(channel); return(BuildRestApiRequest <Uri> (url, PNOperationType.PNDeleteMessagesOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public static Uri BuildSubscribeRequest(string channels, string channelGroups, string timetoken, string channelsJsonState, string region, string filterExpr, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder subscribeParamBuilder = new StringBuilder(); subscribeParamBuilder.AppendFormat("&tt={0}", timetoken); if (!string.IsNullOrEmpty(filterExpr)) { subscribeParamBuilder.AppendFormat("&filter-expr=({0})", Utility.EncodeUricomponent(filterExpr, PNOperationType.PNSubscribeOperation, false, false)); } if (!string.IsNullOrEmpty(region)) { subscribeParamBuilder.AppendFormat("&tr={0}", Utility.EncodeUricomponent(region, PNOperationType.PNSubscribeOperation, false, false)); } if (channelsJsonState != "{}" && channelsJsonState != "") { subscribeParamBuilder.AppendFormat("&state={0}", Utility.EncodeUricomponent(channelsJsonState, PNOperationType.PNSubscribeOperation, false, false)); } if (!string.IsNullOrEmpty(channelGroups)) { subscribeParamBuilder.AppendFormat("&channel-group={0}", Utility.EncodeUricomponent(channelGroups, PNOperationType.PNSubscribeOperation, true, false)); } List <string> url = new List <string> (); url.Add("v2"); url.Add("subscribe"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add(string.IsNullOrEmpty(channels) ? "," : channels); url.Add("0"); return(BuildRestApiRequest <Uri> ( url, PNOperationType.PNSubscribeOperation, subscribeParamBuilder.ToString(), pnInstance, queryParams )); }
public static Uri BuildMessageCountsRequest(string[] channels, string channelsTimetoken, string timetoken, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?timetoken={0}", timetoken); parameterBuilder.AppendFormat("&channelsTimetoken={0}", channelsTimetoken); List <string> url = new List <string> (); url.Add("v3"); url.Add("history"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("message-counts"); url.Add(Utility.EncodeUricomponent(string.Join(",", channels), PNOperationType.PNMessageCountsOperation, true, false)); return(BuildRestApiRequest <Uri> (url, PNOperationType.PNMessageCountsOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public static Uri BuildRemoveChannelsFromChannelGroupRequest(string[] channels, string nameSpace, string groupName, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { bool channelsAvailable = false; string parameters = ""; if (channels != null && channels.Length > 0) { parameters = string.Format("?remove={0}", Utility.EncodeUricomponent(string.Join(",", channels), PNOperationType.PNAddChannelsToGroupOperation, true, false)); channelsAvailable = true; } // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("channel-registration"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); List <string> ns = Utility.CheckAndAddNameSpace(nameSpace); if (ns != null) { url.AddRange(ns); } url.Add("channel-group"); url.Add(groupName); PNOperationType respType = PNOperationType.PNAddChannelsToGroupOperation; if (!channelsAvailable) { url.Add("remove"); respType = PNOperationType.PNRemoveGroupOperation; } return(BuildRestApiRequest <Uri> (url, respType, parameters, pnInstance, queryParams)); }
public static Uri BuildFetchRequest(string[] channels, long start, long end, uint count, bool reverse, bool includeToken, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?max={0}", count); if (includeToken) { parameterBuilder.AppendFormat("&include_token={0}", includeToken.ToString().ToLowerInvariant()); } if (reverse) { parameterBuilder.AppendFormat("&reverse={0}", reverse.ToString().ToLowerInvariant()); } if (start != -1) { parameterBuilder.AppendFormat("&start={0}", start.ToString().ToLowerInvariant()); } if (end != -1) { parameterBuilder.AppendFormat("&end={0}", end.ToString().ToLowerInvariant()); } List <string> url = new List <string> (); url.Add("v3"); url.Add("history"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("channel"); url.Add(Utility.EncodeUricomponent(string.Join(",", channels), PNOperationType.PNFetchMessagesOperation, true, false)); return(BuildRestApiRequest <Uri> (url, PNOperationType.PNFetchMessagesOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
private static Uri BuildRestApiRequest <T> (List <string> urlComponents, PNOperationType type, string parameters, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { string uuid = pnInstance.PNConfig.UUID; bool ssl = pnInstance.PNConfig.Secure; string origin = pnInstance.PNConfig.Origin; int pubnubPresenceHeartbeatInSeconds = pnInstance.PNConfig.PresenceTimeout; string authenticationKey = pnInstance.PNConfig.AuthKey; string pnsdkVersion = pnInstance.Version; StringBuilder url = new StringBuilder(); uuid = Utility.EncodeUricomponent(uuid, type, false, false); url = AddSSLAndOrigin(ssl, origin, url); string urlComponentsEncoded = EncodeURL(urlComponents, type).ToString(); url.Append(urlComponentsEncoded); switch (type) { case PNOperationType.PNLeaveOperation: case PNOperationType.PNSubscribeOperation: case PNOperationType.PNPresenceOperation: url = AppendUUIDToURL(url, uuid, true); url.Append(parameters); url = AppendAuthKeyToURL(url, authenticationKey, type); url = AppendPresenceHeartbeatToURL(url, pubnubPresenceHeartbeatInSeconds); url = AppendPNSDKVersionToURL(url, pnsdkVersion, type); break; case PNOperationType.PNPresenceHeartbeatOperation: case PNOperationType.PNGetStateOperation: case PNOperationType.PNPublishOperation: url = AppendUUIDToURL(url, uuid, true); url.Append(parameters); url = AppendAuthKeyToURL(url, authenticationKey, type); url = AppendPNSDKVersionToURL(url, pnsdkVersion, type); break; case PNOperationType.PNWhereNowOperation: url = AppendUUIDToURL(url, uuid, true); url = AppendAuthKeyToURL(url, authenticationKey, type); url = AppendPNSDKVersionToURL(url, pnsdkVersion, type); break; case PNOperationType.PNPushNotificationEnabledChannelsOperation: case PNOperationType.PNAddPushNotificationsOnChannelsOperation: case PNOperationType.PNRemoveAllPushNotificationsOperation: case PNOperationType.PNRemovePushNotificationsFromChannelsOperation: case PNOperationType.PNAddChannelsToGroupOperation: case PNOperationType.PNRemoveChannelsFromGroupOperation: case PNOperationType.PNSetStateOperation: case PNOperationType.PNHereNowOperation: url.Append(parameters); url = AppendUUIDToURL(url, uuid, false); url = AppendAuthKeyToURL(url, authenticationKey, type); url = AppendPNSDKVersionToURL(url, pnsdkVersion, type); break; case PNOperationType.PNChannelGroupsOperation: case PNOperationType.PNRemoveGroupOperation: case PNOperationType.PNChannelsForGroupOperation: url.Append(parameters); url = AppendUUIDToURL(url, uuid, true); url = AppendAuthKeyToURL(url, authenticationKey, type); url = AppendPNSDKVersionToURL(url, pnsdkVersion, type); break; case PNOperationType.PNDeleteMessagesOperation: url = AppendUUIDToURL(url, uuid, true); url.Append(parameters); url = AppendAuthKeyToURL(url, authenticationKey, type); url = AppendPNSDKVersionToURL(url, pnsdkVersion, type); string urlPath = string.Format("/{0}", string.Join("/", urlComponents.ToArray())); string sig = GenerateSignatureAndAddToURL(pnInstance, new Uri(url.ToString()), urlComponentsEncoded); #if (ENABLE_PUBNUB_LOGGING) UnityEngine.Debug.Log(string.Format("urlComponentsString : {0}\nsig: {1}\nurlPath: {2},\nurlComponentsEncoded: {3}", url, sig, urlPath, urlComponentsEncoded)); #endif url = url.Append(sig); break; case PNOperationType.PNHistoryOperation: case PNOperationType.PNMessageCountsOperation: case PNOperationType.PNFetchMessagesOperation: url.Append(parameters); url = AppendAuthKeyToURL(url, authenticationKey, type); url = AppendUUIDToURL(url, uuid, false); url = AppendPNSDKVersionToURL(url, pnsdkVersion, type); break; default: url = AppendUUIDToURL(url, uuid, true); url = AppendPNSDKVersionToURL(url, pnsdkVersion, type); break; } url = AppendLatencyToURL(url, type, pnInstance.Latency); url = AddQueryParams(url, queryParams); Uri requestUri = new Uri(url.ToString()); return(requestUri); }
public static Uri BuildHistoryRequest(string channel, long start, long end, uint count, bool reverse, bool includeToken, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?count={0}", count); if (includeToken) { parameterBuilder.AppendFormat("&include_token={0}", includeToken.ToString().ToLowerInvariant()); } if (reverse) { parameterBuilder.AppendFormat("&reverse={0}", reverse.ToString().ToLowerInvariant()); } if (start != -1) { parameterBuilder.AppendFormat("&start={0}", start.ToString().ToLowerInvariant()); } if (end != -1) { parameterBuilder.AppendFormat("&end={0}", end.ToString().ToLowerInvariant()); } List <string> url = new List <string> (); url.Add("v2"); url.Add("history"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("channel"); url.Add(channel); return(BuildRestApiRequest <Uri> (url, PNOperationType.PNHistoryOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public GetChannelMetadataRequestBuilder(PubNubUnity pn) : base(pn, PNOperationType.PNGetChannelMetadataOperation) { }
public static Uri BuildHereNowRequest(string channel, string channelGroups, bool showUUIDList, bool includeUserState, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { int disableUUID = (showUUIDList) ? 0 : 1; int userState = (includeUserState) ? 1 : 0; StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?disable_uuids={0}&state={1}", disableUUID, userState); if (!string.IsNullOrEmpty(channelGroups)) { parameterBuilder.AppendFormat("&channel-group={0}", Utility.EncodeUricomponent(channelGroups, PNOperationType.PNHereNowOperation, true, false)); } List <string> url = new List <string> (); url.Add("v2"); url.Add("presence"); url.Add("sub_key"); url.Add(pnInstance.PNConfig.SubscribeKey); if (!string.IsNullOrEmpty(channel)) { url.Add("channel"); url.Add(channel); } else if (string.IsNullOrEmpty(channel) && (!string.IsNullOrEmpty(channelGroups))) { url.Add("channel"); url.Add(","); } return(BuildRestApiRequest <Uri> (url, PNOperationType.PNHereNowOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public RemoveAllPushChannelsForDeviceBuilder(PubNubUnity pn) { pubBuilder = new RemoveAllPushChannelsForDeviceRequestBuilder(pn); }
public static Uri BuildRemoveChannelPushRequest(string channel, PNPushType pushType, string pushToken, PubNubUnity pnInstance, Dictionary <string, string> queryParams) { StringBuilder parameterBuilder = new StringBuilder(); parameterBuilder.AppendFormat("?remove={0}", Utility.EncodeUricomponent(channel, PNOperationType.PNRemoveChannelsFromGroupOperation, true, false)); parameterBuilder.AppendFormat("&type={0}", pushType.ToString().ToLowerInvariant()); // Build URL List <string> url = new List <string>(); url.Add("v1"); url.Add("push"); url.Add("sub-key"); url.Add(pnInstance.PNConfig.SubscribeKey); url.Add("devices"); url.Add(pushToken); return(BuildRestApiRequest <Uri>(url, PNOperationType.PNRemoveChannelsFromGroupOperation, parameterBuilder.ToString(), pnInstance, queryParams)); }
public RemoveUUIDMetadataBuilder(PubNubUnity pn) { removeUUIDMetadataRequestBuilder = new RemoveUUIDMetadataRequestBuilder(pn); }
public DeleteUserRequestBuilder(PubNubUnity pn) : base(pn, PNOperationType.PNDeleteUserOperation) { }