Skip to content

Commit d312fb1

Browse files
implement chat PNSDK logic
1 parent 4010997 commit d312fb1

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

.github/workflows/release/versions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,11 @@
2121
"clearedPrefix": true,
2222
"clearedSuffix": false
2323
}
24+
],
25+
"unity-chat/PubnubChatUnity/Assets/PubnubChat/Runtime/UnityChatPNSDKSource.cs": [
26+
{
27+
"pattern": "^\\s{2,}private const string build = \"(v?(\\.?\\d+){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\";",
28+
"cleared": true
29+
}
2430
]
2531
}

unity-chat/PubnubChatUnity/Assets/PubnubChat/Runtime/UnityChat.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static class UnityChat
2424
/// </remarks>
2525
public static async Task<ChatOperationResult<Chat>> CreateInstance(PubnubChatConfig chatConfig, PNConfiguration pubnubConfig, bool webGLBuildMode = false, bool unityLogging = false)
2626
{
27-
var pubnub = PubnubUnityUtils.NewUnityPubnub(pubnubConfig, webGLBuildMode, unityLogging);
27+
var pubnub = PubnubUnityUtils.NewUnityPubnub(pubnubConfig, webGLBuildMode, unityLogging, new UnityChatPNSDKSource());
2828
return await Chat.CreateInstance(chatConfig, pubnub, new UnityListenerFactory());
2929
}
3030

@@ -43,7 +43,7 @@ public static async Task<ChatOperationResult<Chat>> CreateInstance(PubnubChatCon
4343
/// </remarks>
4444
public static async Task<ChatOperationResult<Chat>> CreateInstance(PubnubChatConfig chatConfig, PNConfigAsset configurationAsset, string userId)
4545
{
46-
var pubnub = PubnubUnityUtils.NewUnityPubnub(configurationAsset, userId);
46+
var pubnub = PubnubUnityUtils.NewUnityPubnub(configurationAsset, userId, new UnityChatPNSDKSource());
4747
return await Chat.CreateInstance(chatConfig, pubnub, new UnityListenerFactory());
4848
}
4949

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using PubnubApi.PNSDK;
2+
3+
namespace PubnubApi.Unity
4+
{
5+
public class UnityChatPNSDKSource : IPNSDKSource
6+
{
7+
private const string build = "0.4.5";
8+
9+
public string GetPNSDK() {
10+
#if(UNITY_IOS)
11+
return string.Format("PubNub-CSharp-Chat-UnityIOS/{0}", build);
12+
#elif(UNITY_STANDALONE_WIN)
13+
return string.Format("PubNub-CSharp-Chat-UnityWin/{0}", build);
14+
#elif(UNITY_STANDALONE_OSX)
15+
return string.Format("PubNub-CSharp-Chat-UnityOSX/{0}", build);
16+
#elif(UNITY_ANDROID)
17+
return string.Format("PubNub-CSharp-Chat-UnityAndroid/{0}", build);
18+
#elif(UNITY_STANDALONE_LINUX)
19+
return string.Format("PubNub-CSharp-Chat-UnityLinux/{0}", build);
20+
#elif(UNITY_WEBPLAYER)
21+
return string.Format("PubNub-CSharp-Chat-UnityWeb/{0}", build);
22+
#elif(UNITY_WEBGL)
23+
return string.Format("PubNub-CSharp-Chat-UnityWebGL/{0}", build);
24+
#else
25+
return string.Format("PubNub-CSharp-Chat-Unity/{0}", build);
26+
#endif
27+
}
28+
}
29+
}

unity-chat/PubnubChatUnity/Assets/PubnubChat/Runtime/UnityChatPNSDKSource.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.

unity-chat/PubnubChatUnity/Packages/packages-lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"com.unity.nuget.newtonsoft-json": "3.0.2"
99
},
10-
"hash": "cea7da962aedb9cac7aae4af5049db37dc3e7dc5"
10+
"hash": "c7e3f452dc9feee8c3396011e157605119186058"
1111
},
1212
"com.unity.collab-proxy": {
1313
"version": "2.6.0",

0 commit comments

Comments
 (0)