Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
---
changelog:
-
changes:
-
text: "Presence Heartbeat call delays itself when a Subscribe call precedes it"
type: improvement
-
text: "Heartbeats per channel"
type: feature
-
text: "QueryParams in all API calls"
type: feature
-
text: "User Exceptions Fix"
type: improvement
-
text: "Leave callback message exception fix"
type: bug
date: "Jan 9, 19"
version: v4.0.5
-
changes:
-
Expand Down Expand Up @@ -271,12 +290,15 @@ features:
- CHANNEL-GROUPS-LIST-CHANNELS-IN-GROUP
others:
- TELEMETRY
- QUERY-PARAM
presence:
- PRESENCE-HERE-NOW
- PRESENCE-WHERE-NOW
- PRESENCE-SET-STATE
- PRESENCE-GET-STATE
- PRESENCE-HEARTBEAT
- PRESENCE-HEARTBEAT-ON-DEMAND
- PRESENCE-HEARTBEAT-THROTTLED
- PRESENCE-HERE-NOW-REFRESH
publish:
- PUBLISH-STORE-FLAG
Expand Down Expand Up @@ -317,7 +339,8 @@ supported-platforms:
-
editors:
- "Unity 5.5.1"
- "Unity 2017.3.0f3"
- "Unity 2017.3.*"
- "Unity 2018.*"
platforms:
- "iOS player, will require iOS 7.0 or higher."
- "Android, OS 2.3.1 or later; ARMv7 (Cortex) CPU with NEON support or Atom CPU; OpenGL ES 2.0 or later."
Expand All @@ -328,4 +351,4 @@ supported-platforms:
- "Ubuntu 12.04+, with Graphics card DX9 (shader model 3.0) or DX11 with feature level 9.3 capabilities; and CPU SSE2 instruction set support."
- "Mac OS X 10.8+, with Graphics card DX9 (shader model 3.0) or DX11 with feature level 9.3 capabilities; and CPU SSE2 instruction set support."
version: "PubNub Unity SDK"
version: v4.0.4
version: v4.0.5
17 changes: 0 additions & 17 deletions FEATURES

This file was deleted.

2 changes: 0 additions & 2 deletions PLATFORM_VERSIONS

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ protected override void RunWebRequest(QueueManager qm){
ChannelsToUse.ToArray(),
"",
ChannelGroupToAdd,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
#if (ENABLE_PUBNUB_LOGGING)
this.PubNubInstance.PNLog.WriteToLog(string.Format("RunPNChannelGroupsAddChannel {0}", request.OriginalString), PNLoggingMethod.LevelInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ protected override void RunWebRequest(QueueManager qm){
null,
"",
ChannelGroupToDelete,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ protected override void RunWebRequest(QueueManager qm){
"",
ChannelGroupToList,
false,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ protected override void RunWebRequest(QueueManager qm){
ChannelsToUse.ToArray(),
"",
ChannelGroupToDelete,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ protected override void RunWebRequest(QueueManager qm){
this.HistoryChannel,
this.StartTime,
this.EndTime,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ protected override void RunWebRequest(QueueManager qm){
this.HistoryCount,
this.ReverseHistory,
this.IncludeTimetokenInHistory,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ protected override void RunWebRequest(QueueManager qm){
this.HistoryCount,
this.ReverseHistory,
this.IncludeTimetokenInHistory,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ protected override void RunWebRequest(QueueManager qm){
channels,
channelGroups,
uuid,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ protected override void RunWebRequest(QueueManager qm){
channelGroups,
IncludeUUIDsInHereNow,
IncludeStateInHereNow,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;

namespace PubNubAPI
{
public class PresenceHeartbeatRequestBuilder: PubNubNonSubBuilder<PresenceHeartbeatRequestBuilder, PNPresenceHeartbeatResult>, IPubNubNonSubscribeBuilder<PresenceHeartbeatRequestBuilder, PNPresenceHeartbeatResult>
{
private bool connected { get; set;}
private Dictionary<string, object> UserState { get; set;}
public PresenceHeartbeatRequestBuilder(PubNubUnity pn): base(pn, PNOperationType.PNPresenceHeartbeatOperation){
}

public void Connected(bool connected){
this.connected = connected;
}
public void State(Dictionary<string, object> state){
this.UserState = state;
}

public void Channels(List<string> channelNames){
ChannelsToUse = channelNames;
}

public void ChannelGroups(List<string> channelGroupNames){
ChannelGroupsToUse = channelGroupNames;
}

#region IPubNubBuilder implementation
public void Async(Action<PNPresenceHeartbeatResult, PNStatus> callback)
{
this.Callback = callback;
RequestState requestState = new RequestState ();
requestState.OperationType = OperationType;
List<ChannelEntity> channelEntities = new List<ChannelEntity>();

string channels = "";
if((ChannelsToUse != null) && (ChannelsToUse.Count>0)){
ChannelsToUse.RemoveAll(t => t.Contains(Utility.PresenceChannelSuffix));
string[] chArr = ChannelsToUse.Where(x => !string.IsNullOrEmpty(x)).Distinct().ToArray();
channels = String.Join(",", chArr);
channelEntities.AddRange(Helpers.CreateChannelEntity(chArr, false, false, null, PubNubInstance.PNLog));
}

string channelGroups = "";
if((ChannelGroupsToUse != null) && (ChannelGroupsToUse.Count>0)){
ChannelGroupsToUse.RemoveAll(t => t.Contains(Utility.PresenceChannelSuffix));
string[] cgArr = ChannelGroupsToUse.Where(x => !string.IsNullOrEmpty(x)).Distinct().ToArray();
channelGroups = String.Join(",", cgArr);
channelEntities.AddRange(Helpers.CreateChannelEntity(cgArr, false, true, null, PubNubInstance.PNLog));
}

if(connected){
PubNubInstance.SubWorker.PHBWorker.RunIndependentOfSubscribe = true;
PubNubInstance.SubWorker.PHBWorker.ChannelGroups = channelGroups;
PubNubInstance.SubWorker.PHBWorker.Channels = channels;
if(UserState!=null){
PubNubInstance.SubWorker.PHBWorker.State = Helpers.BuildJsonUserState(channelEntities);
} else {
PubNubInstance.SubWorker.PHBWorker.State = "";
}
PubNubInstance.SubWorker.PHBWorker.StopPresenceHeartbeat();
PubNubInstance.SubWorker.PHBWorker.RunPresenceHeartbeat(false, PubNubInstance.PNConfig.PresenceInterval);
} else {
PubNubInstance.SubWorker.PHBWorker.RunIndependentOfSubscribe = false;
PubNubInstance.SubWorker.PHBWorker.ChannelGroups = channelGroups;
PubNubInstance.SubWorker.PHBWorker.Channels = channels;
PubNubInstance.SubWorker.PHBWorker.StopPresenceHeartbeat();
PubNubInstance.SubWorker.PHBWorker.RunPresenceHeartbeat(false, PubNubInstance.PNConfig.PresenceInterval);
}
}
#endregion

protected override void RunWebRequest(QueueManager qm){
//No processing here, processing done in async method
}

protected override void CreatePubNubResponse(object deSerializedResult, RequestState requestState){
//No processing here
}

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ protected override void RunWebRequest(QueueManager qm){
channelGroups,
Helpers.BuildJsonUserState(ChannelEntities),
uuid,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ public class WhereNowRequestBuilder: PubNubNonSubBuilder<WhereNowRequestBuilder,
public WhereNowRequestBuilder(PubNubUnity pn): base(pn, PNOperationType.PNWhereNowOperation){
}

public WhereNowRequestBuilder Uuid(string uuidForWhereNow){
public void Uuid(string uuidForWhereNow){
UuidForWhereNow = uuidForWhereNow;
return this;
}
}

#region IPubNubBuilder implementation
public void Async(Action<PNWhereNowResult, PNStatus> callback)
Expand All @@ -37,9 +36,11 @@ protected override void RunWebRequest(QueueManager qm){
if(!string.IsNullOrEmpty(this.UuidForWhereNow)){
uuidForWhereNow = this.UuidForWhereNow;
}

Uri request = BuildRequests.BuildWhereNowRequest(
uuidForWhereNow,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down
6 changes: 6 additions & 0 deletions PubNubUnity/Assets/PubNub/Builders/PubNubNonSubBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public abstract class PubNubNonSubBuilder<U, V> where V : class
{
protected List<string> ChannelGroupsToUse { get; set;}
protected List<string> ChannelsToUse { get; set;}
protected Dictionary<string, string> QueryParams { get; set;}
protected Action<V, PNStatus> Callback;

protected delegate void RunRequestDelegate(QueueManager qm);
Expand All @@ -19,6 +20,11 @@ public abstract class PubNubNonSubBuilder<U, V> where V : class
public PNOperationType OperationType {get; set;}

protected PubNubUnity PubNubInstance;

internal void QueryParam(Dictionary<string, string> queryParam){
QueryParams = queryParam;
}

protected PubNubNonSubBuilder(PubNubUnity pn, PNOperationType pnOperationType){
PubNubInstance = pn;
this.OperationType = pnOperationType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ protected override void RunWebRequest(QueueManager qm){
Uri request = BuildRequests.BuildLeaveRequest(
channels,
channelGroups,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down Expand Up @@ -109,20 +110,23 @@ void RemoveUnsubscribedChannelsAndDeleteUserState(List<ChannelEntity> channelEnt
foreach(ChannelEntity ce in channelEntities)
{
string channelToBeRemoved = ce.ChannelID.ChannelOrChannelGroupName;
PNLeaveRequestResult pnLeaveRequestResult = new PNLeaveRequestResult();
if (this.PubNubInstance.SubscriptionInstance.Delete (ce)) {
string message = string.Format ("{0} Unsubscribed from {1}", (ce.ChannelID.IsPresenceChannel) ? "Presence" : "", channelToBeRemoved.Replace (Utility.PresenceChannelSuffix, ""));
#if (ENABLE_PUBNUB_LOGGING)
this.PubNubInstance.PNLog.WriteToLog (string.Format ("RemoveUnsubscribedChannelsAndDeleteUserState: JSON response={0}", message), PNLoggingMethod.LevelInfo);
#endif
PNStatus pnStatus = base.CreateStatusResponseFromMessage(false, message, null, PNStatusCategory.PNConnectedCategory);
Callback(null, pnStatus);
pnLeaveRequestResult.Message = message;
Callback(pnLeaveRequestResult, pnStatus);
} else {
string message = string.Format("Unsubscribe Error. Please retry the unsubscribe operation. channel{0}", channelToBeRemoved);
#if (ENABLE_PUBNUB_LOGGING)
this.PubNubInstance.PNLog.WriteToLog(string.Format("RemoveUnsubscribedChannelsAndDeleteUserState: channel={0} unsubscribe error", channelToBeRemoved), PNLoggingMethod.LevelInfo);
#endif
PNStatus pnStatus = base.CreateErrorResponseFromMessage(message, null, PNStatusCategory.PNUnknownCategory);
Callback(null, pnStatus);
pnLeaveRequestResult.Message = message;
Callback(pnLeaveRequestResult, pnStatus);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ protected override void RunWebRequest(QueueManager qm){
this.PublishTtl,
UsePostMethod,
this.ReplicateMessage,
this.PubNubInstance
this.PubNubInstance,
this.QueryParams
);
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class SubscribeRequestBuilder
public List<string> ChannelsToUse { get; private set;}
public List<string> ChannelGroupsToUse { get; private set;}

internal Dictionary<string, string> QueryParams { get; private set;}

protected PubNubUnity PubNubInstance { get; set;}

public bool IncludePresenceChannel {get; set;}
Expand Down Expand Up @@ -84,6 +86,7 @@ public void Execute(){
if (channelsOrChannelGroupsAdded){
this.PubNubInstance.SubscriptionInstance.Add (newChannelEntities);
this.PubNubInstance.SubWorker.Add (timetokenToUse, subscribedChannels);
this.PubNubInstance.SubWorker.QueryParams = QueryParams;
}
else {
#if (ENABLE_PUBNUB_LOGGING)
Expand Down Expand Up @@ -121,6 +124,10 @@ public void SetTimeToken(long timetoken){
public void ChannelGroups(List<string> channelGroupNames){
ChannelGroupsToUse = channelGroupNames;
}

public void QueryParam(Dictionary<string, string> queryParam){
QueryParams = queryParam;
}
#endregion
}
}
Loading