Skip to content

Commit 4340ad3

Browse files
authored
Merge pull request #28 from pubnub/develop
Objects and Travis/Appveyor fixes
2 parents 2a38667 + 653a35e commit 4340ad3

File tree

135 files changed

+8722
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+8722
-252
lines changed

.gitignore

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ ExportedObj/
2727
*.booproj
2828
*/.vs/
2929
*.pdb
30+
/PubNubUnity/Library/metadata/*
31+
/PubNubUnity/Library/PackageCache/*.meta
32+
/PubNubUnity/Library/ShaderCache/*
33+
/PubNubUnity/Library/*.log
34+
/PubNubUnity/Library/ScriptAssemblies/*.meta
35+
/PubNubUnity/Logs/*
36+
/PubNubUnity/Library/*.asset
37+
/PubNubUnity/Library/*.txt
38+
/PubNubUnity/Library/*.prefs
39+
/PubNubUnity/Library/*.dwlt
40+
/PubNubUnity/Library/*.db
41+
/PubNubUnity/Assets/*.meta
42+
/PubNubUnity/Library/*.meta
43+
/PubNubUnity/Packages/*.meta
3044

3145
# Unity3D generated meta files
3246
*.pidb.meta
@@ -49,4 +63,4 @@ sysinfo.txt
4963
.Trashes
5064
Icon?
5165
ehthumbs.db
52-
Thumbs.db
66+
Thumbs.db

.pubnub.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
---
22
changelog:
3+
-
4+
changes:
5+
-
6+
text: "Objects"
7+
type: improvement
8+
date: Nov 8, 19
9+
version: v4.4.0
310
-
411
changes:
512
-
@@ -401,4 +408,4 @@ supported-platforms:
401408
- "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."
402409
- "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."
403410
version: "PubNub Unity SDK"
404-
version: v4.3.0
411+
version: v4.4.0

.travis.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ notifications:
55
on_success: never
66
on_failure: change
77

8-
install:
9-
- sudo -E sh ./TravisScripts/install.sh
10-
script:
11-
- sudo -E sh ./TravisScripts/build.sh
12-
deploy:
13-
provider: releases
14-
api_key:
15-
secure: ${s}
16-
file: $(pwd)/${UNITYCI_PROJECT_NAME}/${UNITYCI_PACKAGE_NAME}.unitypackage
17-
skip_cleanup: true
18-
on:
19-
repo: pubnub/unity
20-
#branch: master
21-
tags: true
8+
jobs:
9+
include:
10+
- stage: Install Unity/Run Tests/Export/Deploy
11+
install:
12+
- sudo -E sh ./TravisScripts/install.sh
13+
script:
14+
- sudo -E sh ./TravisScripts/build.sh
15+
deploy:
16+
provider: releases
17+
api_key:
18+
secure: ${s}
19+
file: $(pwd)/${UNITYCI_PROJECT_NAME}/${UNITYCI_PACKAGE_NAME}.unitypackage
20+
skip_cleanup: true
21+
on:
22+
repo: pubnub/unity
23+
#branch: master
24+
tags: true
2225
env:
2326
global:
2427
- UNITYCI_PACKAGE_NAME="PubNub"

AppVeyorScripts/install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$source = "https://download.unity3d.com/download_unity/292b93d75a2c/Windows64EditorInstaller/UnitySetup64.exe"
1+
$source = "https://download.unity3d.com/download_unity/5f859a4cfee5/Windows64EditorInstaller/UnitySetup64.exe"
22
$destination = ".\UnitySetup64.exe"
33
Invoke-WebRequest $source -OutFile $destination
44
Start-Process -FilePath ".\UnitySetup64.exe" -Wait -ArgumentList ('/S', '/Q')

AppVeyorScripts/test.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
$testResultsFile = "C:\temp\results.xml"
2-
Start-Process -Wait -FilePath Unity.exe -ArgumentList ('-batchmode', '-nographics', '-logFile', 'C:\temp\unity.log', '-runTests', '-projectPath', 'c:\projects\unity\PubNubUnity', '-testResults', $testResultsFile, '-testPlatform', 'editmode', '-quit')
2+
Start-Process -Wait -FilePath Unity.exe -ArgumentList ('-batchmode', '-nographics', '-logFile', 'C:\temp\unity.log', '-runEditorTests', '-projectPath', 'c:\projects\unity\PubNubUnity', '-editorTestsResultFile', $testResultsFile, '-testResults', $testResultsFile, '-testPlatform', 'editmode', '-quit')
33
$res = Invoke-Pester -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru
44
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
55
if ($res.FailedCount -gt 0) {
66
throw "$($res.FailedCount) tests failed."
77
}
88

99
$testResultsFile2 = "C:\temp\results2.xml"
10-
Start-Process -Wait -FilePath Unity.exe -ArgumentList ('-batchmode', '-nographics', '-logFile', 'C:\temp\unity.log', '-runTests', '-projectPath', 'c:\projects\unity\PubNubUnity', '-testResults', $testResultsFile2, '-testPlatform', 'playmode', '-quit')
10+
Start-Process -Wait -FilePath Unity.exe -ArgumentList ('-batchmode', '-nographics', '-logFile', 'C:\temp\unity.log', '-runEditorTests', '-projectPath', 'c:\projects\unity\PubNubUnity', '-testResults', $testResultsFile2, '-testPlatform', 'playmode', '-quit')
1111
$res2 = Invoke-Pester -OutputFormat NUnitXml -OutputFile $testResultsFile2 -PassThru
1212
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile2))
1313
if ($res2.FailedCount -gt 0) {

PubNubUnity/Assets/PubNub/Builders/Objects.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
using System;
2+
using System.Linq;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
6+
namespace PubNubAPI
7+
{
8+
public class CreateSpaceRequestBuilder: PubNubNonSubBuilder<CreateSpaceRequestBuilder, PNSpaceResult>, IPubNubNonSubscribeBuilder<CreateSpaceRequestBuilder, PNSpaceResult>
9+
{
10+
private PNUserSpaceInclude[] CreateSpaceInclude { get; set;}
11+
private string CreateSpaceID { get; set;}
12+
private string CreateSpaceName { get; set;}
13+
private string CreateSpaceDescription { get; set;}
14+
private Dictionary<string, object> CreateSpaceCustom { get; set;}
15+
16+
public CreateSpaceRequestBuilder(PubNubUnity pn): base(pn, PNOperationType.PNCreateSpaceOperation){
17+
}
18+
19+
#region IPubNubBuilder implementation
20+
public void Async(Action<PNSpaceResult, PNStatus> callback)
21+
{
22+
this.Callback = callback;
23+
base.Async(this);
24+
}
25+
#endregion
26+
27+
public CreateSpaceRequestBuilder Include(PNUserSpaceInclude[] include){
28+
CreateSpaceInclude = include;
29+
return this;
30+
}
31+
32+
public CreateSpaceRequestBuilder ID(string id){
33+
CreateSpaceID = id;
34+
return this;
35+
}
36+
37+
public CreateSpaceRequestBuilder Name(string name){
38+
CreateSpaceName = name;
39+
return this;
40+
}
41+
42+
public CreateSpaceRequestBuilder Description(string description){
43+
CreateSpaceDescription = description;
44+
return this;
45+
}
46+
47+
public CreateSpaceRequestBuilder Custom(Dictionary<string, object> custom){
48+
CreateSpaceCustom = custom;
49+
return this;
50+
}
51+
52+
protected override void RunWebRequest(QueueManager qm){
53+
RequestState requestState = new RequestState ();
54+
requestState.OperationType = OperationType;
55+
requestState.httpMethod = HTTPMethod.Post;
56+
57+
var cub = new {
58+
id = CreateSpaceID,
59+
name = CreateSpaceName,
60+
description = CreateSpaceDescription,
61+
custom = CreateSpaceCustom,
62+
};
63+
64+
string jsonUserBody = Helpers.JsonEncodePublishMsg (cub, "", this.PubNubInstance.JsonLibrary, this.PubNubInstance.PNLog);
65+
#if (ENABLE_PUBNUB_LOGGING)
66+
this.PubNubInstance.PNLog.WriteToLog (string.Format ("jsonUserBody: {0}", jsonUserBody), PNLoggingMethod.LevelInfo);
67+
#endif
68+
requestState.POSTData = jsonUserBody;
69+
70+
string[] includeString = (CreateSpaceInclude==null) ? new string[]{} : CreateSpaceInclude.Select(a=>a.GetDescription().ToString()).ToArray();
71+
72+
Uri request = BuildRequests.BuildObjectsCreateSpaceRequest(
73+
string.Join(",", includeString),
74+
this.PubNubInstance,
75+
this.QueryParams
76+
);
77+
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
78+
}
79+
80+
protected override void CreatePubNubResponse(object deSerializedResult, RequestState requestState){
81+
PNSpaceResult pnSpaceResult = new PNSpaceResult();
82+
PNStatus pnStatus = new PNStatus();
83+
84+
try{
85+
Dictionary<string, object> dictionary = deSerializedResult as Dictionary<string, object>;
86+
87+
if(dictionary != null) {
88+
object objData;
89+
dictionary.TryGetValue("data", out objData);
90+
if(objData!=null){
91+
Dictionary<string, object> objDataDict = objData as Dictionary<string, object>;
92+
if(objDataDict!=null){
93+
pnSpaceResult = ObjectsHelpers.ExtractSpace(objDataDict);
94+
} else {
95+
pnSpaceResult = null;
96+
pnStatus = base.CreateErrorResponseFromException(new PubNubException("objDataDict null"), requestState, PNStatusCategory.PNUnknownCategory);
97+
}
98+
} else {
99+
pnSpaceResult = null;
100+
pnStatus = base.CreateErrorResponseFromException(new PubNubException("objData null"), requestState, PNStatusCategory.PNUnknownCategory);
101+
}
102+
}
103+
} catch (Exception ex){
104+
pnSpaceResult = null;
105+
pnStatus = base.CreateErrorResponseFromException(ex, requestState, PNStatusCategory.PNUnknownCategory);
106+
}
107+
Callback(pnSpaceResult, pnStatus);
108+
109+
}
110+
111+
}
112+
}

PubNubUnity/Assets/PubNub/Builders/Objects/CreateSpaceRequestBuilder.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
using System;
2+
using System.Linq;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
6+
namespace PubNubAPI
7+
{
8+
public class CreateUserRequestBuilder: PubNubNonSubBuilder<CreateUserRequestBuilder, PNUserResult>, IPubNubNonSubscribeBuilder<CreateUserRequestBuilder, PNUserResult>
9+
{
10+
private PNUserSpaceInclude[] CreateUserInclude { get; set;}
11+
private string CreateUserID { get; set;}
12+
private string CreateUserName { get; set;}
13+
private string CreateUserExternalID { get; set;}
14+
private string CreateUserProfileURL { get; set;}
15+
private string CreateUserEmail { get; set;}
16+
private Dictionary<string, object> CreateUserCustom { get; set;}
17+
18+
public CreateUserRequestBuilder(PubNubUnity pn): base(pn, PNOperationType.PNCreateUserOperation){
19+
}
20+
21+
#region IPubNubBuilder implementation
22+
public void Async(Action<PNUserResult, PNStatus> callback)
23+
{
24+
this.Callback = callback;
25+
base.Async(this);
26+
}
27+
#endregion
28+
29+
public CreateUserRequestBuilder Include(PNUserSpaceInclude[] include){
30+
CreateUserInclude = include;
31+
return this;
32+
}
33+
34+
public CreateUserRequestBuilder ID(string id){
35+
CreateUserID = id;
36+
return this;
37+
}
38+
39+
public CreateUserRequestBuilder Name(string name){
40+
CreateUserName = name;
41+
return this;
42+
}
43+
44+
public CreateUserRequestBuilder ExternalID(string externalID){
45+
CreateUserExternalID = externalID;
46+
return this;
47+
}
48+
49+
public CreateUserRequestBuilder ProfileURL(string profileURL){
50+
CreateUserProfileURL = profileURL;
51+
return this;
52+
}
53+
54+
public CreateUserRequestBuilder Email(string email){
55+
CreateUserEmail = email;
56+
return this;
57+
}
58+
59+
public CreateUserRequestBuilder Custom(Dictionary<string, object> custom){
60+
CreateUserCustom = custom;
61+
return this;
62+
}
63+
64+
protected override void RunWebRequest(QueueManager qm){
65+
RequestState requestState = new RequestState ();
66+
requestState.OperationType = OperationType;
67+
requestState.httpMethod = HTTPMethod.Post;
68+
69+
var cub = new {
70+
id = CreateUserID,
71+
email = CreateUserEmail,
72+
name = CreateUserName,
73+
profileUrl = CreateUserProfileURL,
74+
externalId = CreateUserExternalID,
75+
custom = CreateUserCustom,
76+
};
77+
78+
string jsonUserBody = Helpers.JsonEncodePublishMsg (cub, "", this.PubNubInstance.JsonLibrary, this.PubNubInstance.PNLog);
79+
#if (ENABLE_PUBNUB_LOGGING)
80+
this.PubNubInstance.PNLog.WriteToLog (string.Format ("jsonUserBody: {0}", jsonUserBody), PNLoggingMethod.LevelInfo);
81+
#endif
82+
requestState.POSTData = jsonUserBody;
83+
84+
string[] includeString = (CreateUserInclude==null) ? new string[]{} : CreateUserInclude.Select(a=>a.GetDescription().ToString()).ToArray();
85+
86+
Uri request = BuildRequests.BuildObjectsCreateUserRequest(
87+
string.Join(",", includeString),
88+
this.PubNubInstance,
89+
this.QueryParams
90+
);
91+
base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
92+
}
93+
94+
protected override void CreatePubNubResponse(object deSerializedResult, RequestState requestState){
95+
PNUserResult pnUserResult = new PNUserResult();
96+
PNStatus pnStatus = new PNStatus();
97+
98+
Debug.Log("=======>" + deSerializedResult.ToString());
99+
100+
try{
101+
Debug.Log("=======> dictionary");
102+
Dictionary<string, object> dictionary = deSerializedResult as Dictionary<string, object>;
103+
104+
if(dictionary != null) {
105+
object objData;
106+
dictionary.TryGetValue("data", out objData);
107+
if(objData!=null){
108+
Dictionary<string, object> objDataDict = objData as Dictionary<string, object>;
109+
if(objDataDict != null){
110+
pnUserResult = ObjectsHelpers.ExtractUser(objDataDict);
111+
Debug.Log("=======> pnUserResult" + pnUserResult);
112+
} else {
113+
pnUserResult = null;
114+
pnStatus = base.CreateErrorResponseFromException(new PubNubException("objDataDict null"), requestState, PNStatusCategory.PNUnknownCategory);
115+
}
116+
} else {
117+
Debug.Log("=======> objData null");
118+
pnUserResult = null;
119+
pnStatus = base.CreateErrorResponseFromException(new PubNubException("objData null"), requestState, PNStatusCategory.PNUnknownCategory);
120+
}
121+
} else {
122+
Debug.Log("=======> dictionary null");
123+
}
124+
} catch (Exception ex){
125+
Debug.Log("=======>" + ex.ToString());
126+
127+
pnUserResult = null;
128+
pnStatus = base.CreateErrorResponseFromException(ex, requestState, PNStatusCategory.PNUnknownCategory);
129+
}
130+
Callback(pnUserResult, pnStatus);
131+
132+
}
133+
134+
}
135+
}

PubNubUnity/Assets/PubNub/Builders/Objects/CreateUserRequestBuilder.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)