Skip to content

Commit d2f7a40

Browse files
authored
Merge pull request #448 from watson-developer-cloud/rc-2.8.0
Watson Unity SDK 2.8.0
2 parents b03e7d6 + 4ad8a86 commit d2f7a40

File tree

10 files changed

+88
-79
lines changed

10 files changed

+88
-79
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,4 @@ Docs/publishing-release.md.meta
7777
**/.swagger-codegen
7878
/Scripts/Editor/Help/
7979
/Scripts/Editor/Help.meta
80+
*/MRefBuilder.config.meta

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "IBM Watson SDK for Unity"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 2.7.0
41+
PROJECT_NUMBER = 2.8.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

Scripts/Connection/WSConnector.cs

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222
using IBM.Watson.DeveloperCloud.Utilities;
2323
using System.Collections;
2424
using System.Collections.Generic;
25-
using System.Threading;
26-
#if UNITY_2018_2_OR_NEWER
2725
using System.Security.Authentication;
28-
#endif
29-
26+
using System.Threading;
3027
#if !NETFX_CORE
3128
using UnitySDK.WebSocketSharp;
3229
#else
@@ -193,6 +190,8 @@ public Dictionary<string, string> Headers {
193190
private AutoResetEvent _receiveEvent = new AutoResetEvent(false);
194191
private Queue<Message> _receiveQueue = new Queue<Message>();
195192
private int _receiverRoutine = 0;
193+
private static readonly string https = "https://";
194+
private static readonly string wss = "wss://";
196195
#endregion
197196

198197
/// <summary>
@@ -203,78 +202,76 @@ public Dictionary<string, string> Headers {
203202
public static string FixupURL(string URL)
204203
{
205204
#if UNITY_2018_2_OR_NEWER
205+
#if NET_4_6
206206
// Use standard endpoints since 2018.2 supports TLS 1.2
207-
if (URL.StartsWith("http://stream."))
208-
{
209-
URL = URL.Replace("http://stream.", "ws://stream.");
210-
}
211-
else if (URL.StartsWith("https://stream."))
207+
if (URL.StartsWith("https://stream."))
212208
{
213209
URL = URL.Replace("https://stream.", "wss://stream.");
214210
}
215211

216-
// TLS 1.0 endpoint
217-
else if (URL.StartsWith("http://stream-tls10."))
218-
{
219-
URL = URL.Replace("http://stream-tls10.", "ws://stream.");
220-
}
212+
// TLS 1.0 endpoint - Do not change this to TLS 1.2 endpoint since
213+
// users may need to use the TLS 1.0 endpoint because of different
214+
// platforms.
221215
else if (URL.StartsWith("https://stream-tls10."))
222216
{
223-
URL = URL.Replace("https://stream-tls10.", "wss://stream.");
217+
URL = URL.Replace("https://stream-tls10.", "wss://stream-tls10.");
224218
}
225-
226219
// Germany
227-
else if (URL.StartsWith("http://gateway-fra."))
228-
{
229-
URL = URL.Replace("http://gateway-fra.", "ws://stream-fra.");
230-
}
231220
else if (URL.StartsWith("https://gateway-fra."))
232221
{
233222
URL = URL.Replace("https://gateway-fra.", "wss://stream-fra.");
234223
}
235-
236224
// US East
237-
else if (URL.StartsWith("http://gateway-wdc."))
238-
{
239-
URL = URL.Replace("http://gateway-wdc.", "ws://gateway-wdc.");
240-
}
241225
else if (URL.StartsWith("https://gateway-wdc."))
242226
{
243227
URL = URL.Replace("https://gateway-wdc.", "wss://gateway-wdc.");
244228
}
245-
246-
247229
// Sydney
248-
else if (URL.StartsWith("http://gateway-syd."))
249-
{
250-
URL = URL.Replace("http://gateway-syd.", "ws://gateway-syd.");
251-
}
252230
else if (URL.StartsWith("https://gateway-syd."))
253231
{
254232
URL = URL.Replace("https://gateway-syd.", "wss://gateway-syd.");
255233
}
256-
257234
else
258235
{
259-
Log.Warning("WSConnector", "No case for URL for wss://. Leaving URL unchanged.");
236+
URL = URL.Replace(https, wss);
237+
Log.Warning("WSConnector", "No case for URL for wss://. Replacing https:// with wss://.");
238+
}
239+
#else
240+
// Use TLS 1.0 endpoint if user is on .NET 3.5. US South is the
241+
// only region that supports this endpoint.
242+
if (URL.StartsWith("https://stream."))
243+
{
244+
URL = URL.Replace("https://stream.", "wss://stream-tls10.");
245+
}
246+
else if (URL.StartsWith("https://stream-tls10."))
247+
{
248+
URL = URL.Replace("https://stream-tls10.", "wss://stream-tls10.");
249+
}
250+
else
251+
{
252+
URL = URL.Replace(https, wss);
253+
Log.Warning("WSConnector", "No case for URL for wss://. Replacing https:// with wss://.");
254+
Log.Warning("WSConnector", "Streaming with TLS 1.0 is only available in US South. Please create your Speech to Text instance in US South. Alternatviely, use Unity 2018.2 with .NET 4.x Scripting Runtime Version enabled (File > Build Settings > Player Settings > Other Settings > Scripting Runtime Version).");
260255
}
256+
#endif
261257
#else
262-
// Redirect to TLS 1.0 endpoints.
263-
// Note frankfurt endpoint does not support TLS 1.0.
264-
if (URL.StartsWith("http://stream."))
265-
URL = URL.Replace("http://stream.", "ws://stream-tls10.");
266-
else if (URL.StartsWith("https://stream."))
258+
// Use TLS 1.0 endpoint if user is on .NET 3.5 or 4.6 if using Unity 2018.1 or older.
259+
// US South is the only region that supports this endpoint.
260+
if (URL.StartsWith("https://stream."))
261+
{
267262
URL = URL.Replace("https://stream.", "wss://stream-tls10.");
268-
else if (URL.StartsWith("http://stream-tls10."))
269-
URL = URL.Replace("http://stream-tls10.", "ws://stream-tls10.");
263+
}
270264
else if (URL.StartsWith("https://stream-tls10."))
265+
{
271266
URL = URL.Replace("https://stream-tls10.", "wss://stream-tls10.");
272-
else if (URL.StartsWith("http://stream-fra."))
273-
URL = URL.Replace("http://stream-fra.", "ws://stream-fra.");
274-
else if (URL.StartsWith("https://stream-fra."))
275-
URL = URL.Replace("https://stream-fra.", "wss://stream-fra.");
267+
}
268+
else
269+
{
270+
URL = URL.Replace(https, wss);
271+
Log.Warning("WSConnector", "No case for URL for wss://. Replacing https:// with wss://.");
272+
Log.Warning("WSConnector", "Streaming with TLS 1.0 is only available in US South. Please create your Speech to Text instance in US South. Alternatviely, use Unity 2018.2 with .NET 4.x Scripting Runtime Version enabled (File > Build Settings > Player Settings > Other Settings > Scripting Runtime Version).");
273+
}
276274
#endif
277-
278275
return URL;
279276
}
280277

@@ -307,7 +304,7 @@ public static WSConnector CreateConnector(Credentials credentials, string functi
307304
return connector;
308305
}
309306

310-
#region Public Functions
307+
#region Public Functions
311308
/// <summary>
312309
/// This function sends the given message object.
313310
/// </summary>
@@ -359,9 +356,9 @@ public void Close()
359356
// setting the state to closed will make the SendThread automatically exit.
360357
_connectionState = ConnectionState.CLOSED;
361358
}
362-
#endregion
359+
#endregion
363360

364-
#region Private Functions
361+
#region Private Functions
365362
private IEnumerator ProcessReceiveQueue()
366363
{
367364
while (_connectionState == ConnectionState.CONNECTED
@@ -392,10 +389,10 @@ private IEnumerator ProcessReceiveQueue()
392389
if (OnClose != null)
393390
OnClose(this);
394391
}
395-
#endregion
392+
#endregion
396393

397-
#region Threaded Functions
398-
// NOTE: ALl functions in this region are operating in a background thread, do NOT call any Unity functions!
394+
#region Threaded Functions
395+
// NOTE: All functions in this region are operating in a background thread, do NOT call any Unity functions!
399396
#if !NETFX_CORE
400397
private void SendMessages()
401398
{
@@ -412,8 +409,12 @@ private void SendMessages()
412409
ws.OnClose += OnWSClose;
413410
ws.OnError += OnWSError;
414411
ws.OnMessage += OnWSMessage;
415-
#if UNITY_2018_2_OR_NEWER
412+
#if NET_4_6
413+
// Enable TLS 1.1 and TLS 1.2 if we are on .NET 4.x
416414
ws.SslConfiguration.EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;
415+
#else
416+
// .NET 3.x does not support TLS 1.1 or TLS 1.2
417+
ws.SslConfiguration.EnabledSslProtocols = SslProtocols.Tls;
417418
#endif
418419
ws.Connect();
419420

@@ -589,6 +590,6 @@ private void WebSocket_MessageReceived(MessageWebSocket sender, MessageWebSocket
589590
}
590591
}
591592
#endif
592-
#endregion
593+
#endregion
593594
}
594595
}

Scripts/Editor/Help/Working/MRefBuilder.config.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Scripts/Services/Assistant/v1/Model/MessageResponse.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public class MessageResponse
6262
/// <value>Output from the dialog, including the response to the user, the nodes that were triggered, and log messages.</value>
6363
[fsProperty("output")]
6464
public object Output { get; set; }
65+
/// <summary>
66+
/// An array of objects describing any actions requested by the dialog node.
67+
/// </summary>
68+
[fsProperty("actions")]
69+
public object Actions { get; set; }
6570
}
6671

6772
}

Scripts/Services/Assistant/v1/Model/OutputData.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public class OutputData
5656
/// <value>An array of objects containing detailed diagnostic information about the nodes that were triggered during processing of the input message. Included only if **nodes_visited_details** is set to `true` in the message request.</value>
5757
[fsProperty("nodes_visited_details")]
5858
public Dictionary<string, object> NodesVisitedDetails { get; set; }
59+
// <summary>
60+
/// An array of objects describing any actions requested by the dialog node.
61+
/// </summary>
62+
[fsProperty("actions")]
63+
public Dictionary<string, object> Actions { get; set; }
5964
}
6065

6166
}

Scripts/UnitTests/TestAssistantCF.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class TestAssistantCF : UnitTest
4040
private fsSerializer _serializer = new fsSerializer();
4141

4242
private string _inputString = "Hello";
43-
private string _conversationString0 = "unlock the door";
44-
private string _conversationString1 = "turn on the ac";
45-
private string _conversationString2 = "turn down the radio";
43+
private string _conversationString0 = "Are you open on christmas?";
44+
private string _conversationString1 = "Can you connect me to a real person?";
45+
private string _conversationString2 = "goodbye";
4646
private static string _lastIntent = null;
4747

4848
private static string _createdWorkspaceName = "unity-sdk-example-workspace-delete";

Scripts/UnitTests/TestDiscovery.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public class TestDiscovery : UnitTest
6969
private bool _deleteConfigurationTested = false;
7070
private bool _isEnvironmentReady = false;
7171
private bool _deleteUserDataTested = false;
72-
private bool _readyToContinue = false;
7372

7473
private bool _listCredentialsTested = false;
7574
private bool _createCredentialsTested = false;
@@ -332,7 +331,6 @@ public override IEnumerator RunTest()
332331
while (!_isEnvironmentReady)
333332
yield return null;
334333

335-
_readyToContinue = false;
336334
// Delete Collection
337335
Log.Debug("TestDiscovery.RunTest()", "Attempting to delete collection {0}", _createdCollectionId);
338336
if (!_discovery.DeleteCollection(OnDeleteCollection, OnFail, _environmentId, _createdCollectionId))
@@ -345,7 +343,6 @@ public override IEnumerator RunTest()
345343
while (!_isEnvironmentReady)
346344
yield return null;
347345

348-
_readyToContinue = false;
349346
// Delete Configuration
350347
Log.Debug("TestDiscovery.RunTest()", "Attempting to delete configuration {0}", _createdConfigurationID);
351348
if (!_discovery.DeleteConfiguration(OnDeleteConfiguration, OnFail, _environmentId, _createdConfigurationID))

Scripts/Utilities/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static class Path
4747
public static class String
4848
{
4949
/// <exclude />
50-
public const string Version = "watson-apis-unity-sdk/2.7.0";
50+
public const string Version = "watson-apis-unity-sdk/2.8.0";
5151
/// <exclude />
5252
public const string DebugDispalyQuality = "Quality: {0}";
5353
/// <summary>

Scripts/Utilities/Credentials.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class Credentials
3636
private string _iamApiKey;
3737
private string _userAcessToken;
3838
private const string APIKEY_AS_USERNAME = "apikey";
39+
private const string ICP_PREFIX = "icp-";
3940
#endregion
4041

4142
#region Public Fields
@@ -146,7 +147,7 @@ public Credentials(TokenOptions iamTokenOptions, string serviceUrl = null)
146147
#region SetCredentials
147148
private void SetCredentials(string username, string password, string url = null)
148149
{
149-
if (username == APIKEY_AS_USERNAME)
150+
if (username == APIKEY_AS_USERNAME && !password.StartsWith(ICP_PREFIX))
150151
{
151152
TokenOptions tokenOptions = new TokenOptions()
152153
{
@@ -167,18 +168,25 @@ private void SetCredentials(string username, string password, string url = null)
167168

168169
private void SetCredentials(TokenOptions iamTokenOptions, string serviceUrl = null)
169170
{
170-
if (!string.IsNullOrEmpty(serviceUrl))
171-
Url = serviceUrl;
172-
_iamUrl = !string.IsNullOrEmpty(iamTokenOptions.IamUrl) ? iamTokenOptions.IamUrl : "https://iam.bluemix.net/identity/token";
173-
_iamTokenData = new IamTokenData();
171+
if (iamTokenOptions.IamApiKey.StartsWith(ICP_PREFIX))
172+
{
173+
SetCredentials(APIKEY_AS_USERNAME, iamTokenOptions.IamApiKey, serviceUrl);
174+
}
175+
else
176+
{
177+
if (!string.IsNullOrEmpty(serviceUrl))
178+
Url = serviceUrl;
179+
_iamUrl = !string.IsNullOrEmpty(iamTokenOptions.IamUrl) ? iamTokenOptions.IamUrl : "https://iam.bluemix.net/identity/token";
180+
_iamTokenData = new IamTokenData();
174181

175-
if (!string.IsNullOrEmpty(iamTokenOptions.IamApiKey))
176-
_iamApiKey = iamTokenOptions.IamApiKey;
182+
if (!string.IsNullOrEmpty(iamTokenOptions.IamApiKey))
183+
_iamApiKey = iamTokenOptions.IamApiKey;
177184

178-
if (!string.IsNullOrEmpty(iamTokenOptions.IamAccessToken))
179-
this._userAcessToken = iamTokenOptions.IamAccessToken;
185+
if (!string.IsNullOrEmpty(iamTokenOptions.IamAccessToken))
186+
this._userAcessToken = iamTokenOptions.IamAccessToken;
180187

181-
GetToken();
188+
GetToken();
189+
}
182190
}
183191
#endregion
184192

0 commit comments

Comments
 (0)