diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 6d92c049..f17de96b 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -33,7 +33,7 @@ jobs: run: | rm -rf ./project/EmptyProject/Assets/Tests/Editor rm ./project/EmptyProject/Assets/Tests/Editor.meta - + - name: Run Tests using Unity TestRunner uses: game-ci/unity-test-runner@v2 id: tests diff --git a/Editor/MobiledgeXEditorWindow.cs b/Editor/MobiledgeXEditorWindow.cs index cc67d5da..d65edbac 100644 --- a/Editor/MobiledgeXEditorWindow.cs +++ b/Editor/MobiledgeXEditorWindow.cs @@ -1,5 +1,5 @@ /** - * Copyright 2018-2021 MobiledgeX, Inc. All rights and licenses reserved. + * Copyright 2018-2022 MobiledgeX, Inc. All rights and licenses reserved. * MobiledgeX, Inc. 156 2nd Street #408, San Francisco, CA 94105 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -224,8 +224,12 @@ void OnInspectorUpdate() string GetSDKVersion() { TextAsset asset = (TextAsset)AssetDatabase.LoadAssetAtPath("Packages/com.mobiledgex.sdk/package.json", typeof(TextAsset)); - string sdkVersion = JsonUtility.FromJson(asset.text).version; - return "v" + sdkVersion; + if (asset != null) + { + string sdkVersion = JsonUtility.FromJson(asset.text).version; + return "v" + sdkVersion; + } + return "DEBUG_VER"; } /// @@ -441,7 +445,6 @@ void AddMobiledgeXPlugins() string iosPluginPath = Path.GetFullPath("Packages/com.mobiledgex.sdk/Runtime/Plugins/iOS/PlatformIntegration.m"); string linkXMLPath = Path.GetFullPath("Packages/com.mobiledgex.sdk/link.xml"); string settingPath = Path.GetFullPath("Packages/com.mobiledgex.sdk/Resources/MobiledgeXSettings.asset"); - string melAARPath = Path.GetFullPath("Packages/com.mobiledgex.sdk/Runtime/Plugins/Android/mel.aar"); try { if (!Directory.Exists(@unityPluginsFolderPath)) @@ -468,7 +471,6 @@ void AddMobiledgeXPlugins() { AssetDatabase.CreateFolder("Assets/Plugins/MobiledgeX", "Android"); } - MoveFile(melAARPath, Path.Combine(@mobiledgeXFolderPath, @"Android/mel.aar"), true); AssetDatabase.Refresh(); } catch (Exception e) diff --git a/Runtime/Plugins/Android.meta b/Runtime/Plugins/Android.meta deleted file mode 100644 index 6afc8856..00000000 --- a/Runtime/Plugins/Android.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b38684a80edc040678173b245ee173a2 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Plugins/Android/mel.aar b/Runtime/Plugins/Android/mel.aar deleted file mode 100644 index 7f8ca334..00000000 Binary files a/Runtime/Plugins/Android/mel.aar and /dev/null differ diff --git a/Runtime/Plugins/Android/mel.aar.meta b/Runtime/Plugins/Android/mel.aar.meta deleted file mode 100644 index dbfedb23..00000000 --- a/Runtime/Plugins/Android/mel.aar.meta +++ /dev/null @@ -1,32 +0,0 @@ -fileFormatVersion: 2 -guid: 4f54887943de744f686b235b33eea969 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Android: Android - second: - enabled: 1 - settings: {} - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Plugins/MatchingEngineSDKRestLibrary.dll b/Runtime/Plugins/MatchingEngineSDKRestLibrary.dll index dbf5e34c..c8dc5b95 100644 Binary files a/Runtime/Plugins/MatchingEngineSDKRestLibrary.dll and b/Runtime/Plugins/MatchingEngineSDKRestLibrary.dll differ diff --git a/Runtime/Scripts/MelMessaging.cs b/Runtime/Scripts/MelMessaging.cs deleted file mode 100644 index 591a2d78..00000000 --- a/Runtime/Scripts/MelMessaging.cs +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright 2018-2021 MobiledgeX, Inc. All rights and licenses reserved. - * MobiledgeX, Inc. 156 2nd Street #408, San Francisco, CA 94105 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using UnityEngine; -using MobiledgeX; -using DistributedMatchEngine.Mel; - -public class MelMessaging : MelMessagingInterface -{ - -#if UNITY_ANDROID - AndroidJavaObject getActivity() - { - AndroidJavaClass unityPlayer = PlatformIntegrationUtil.GetAndroidJavaClass("com.unity3d.player.UnityPlayer"); - if (unityPlayer == null) - { - return null; - } - AndroidJavaObject activity = PlatformIntegrationUtil.GetStatic(unityPlayer, "currentActivity"); - if (activity == null) - { - return null; - } - return activity; - } - - AndroidJavaClass getMel() - { - AndroidJavaClass MelCls = PlatformIntegrationUtil.GetAndroidJavaClass("com.mobiledgex.mel.MelMessaging"); - return MelCls; - } - - public MelMessaging(string appName) - { - // MobiledgeX Vender Interface. Only for Android. - AndroidJavaClass MelCls = getMel(); - - // Fire off intents to update MEL state. - var activity = getActivity(); - if (activity == null) - { - return; - } - MelCls.CallStatic("sendForMelStatus", activity, appName); - } - - public bool IsMelEnabled() - { - AndroidJavaClass MelCls = getMel(); - if (MelCls == null) - { - return false; - } - bool enabled = PlatformIntegrationUtil.CallStatic(MelCls, "isMelEnabled"); - return enabled; - } - - public string GetMelVersion() - { - AndroidJavaClass MelCls = getMel(); - if (MelCls == null) - { - return ""; - } - return PlatformIntegrationUtil.CallStatic(MelCls, "getMelVersion"); - } - - public string GetUid() - { - AndroidJavaClass MelCls = getMel(); - if (MelCls == null) - { - return ""; - } - string uid = PlatformIntegrationUtil.CallStatic(MelCls, "getUid"); - return uid; - } - - public string SetToken(string token, string app_name) - { - AndroidJavaClass MelCls = getMel(); - if (MelCls == null) - { - return ""; - } - object[] pa = new object[3] { getActivity(), token, app_name }; - string sent_token = PlatformIntegrationUtil.CallStatic(MelCls, "sendSetToken", pa); - return sent_token; - } - - // MelMessaging related: - public string GetManufacturer() - { - AndroidJavaClass BuildCls = PlatformIntegrationUtil.GetAndroidJavaClass("android.os.Build"); - string manufacturer = PlatformIntegrationUtil.GetStatic(BuildCls, "MANUFACTURER"); - return manufacturer; - } -#elif UNITY_IOS - public MelMessaging(string app_name) { } - public bool IsMelEnabled() { return false; } - public string GetMelVersion() { return ""; } - public string SetToken(string token, string app_name) { return ""; } - public string GetUid() { return ""; } - public string GetManufacturer() { return "Apple"; } -#else - public MelMessaging(string app_name) { } - public bool IsMelEnabled() { return false; } - public string GetMelVersion() { return ""; } - public string SetToken(string token, string app_name) { return ""; } - public string GetUid() { return ""; } - public string GetManufacturer() { return ""; } -#endif -} diff --git a/Runtime/Scripts/MelMessaging.cs.meta b/Runtime/Scripts/MelMessaging.cs.meta deleted file mode 100644 index 17f1d925..00000000 --- a/Runtime/Scripts/MelMessaging.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a7340f008066f436c80eb93ec935e0f8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Scripts/MobiledgeXIntegration.cs b/Runtime/Scripts/MobiledgeXIntegration.cs index 3a1c5f67..6d4620ed 100644 --- a/Runtime/Scripts/MobiledgeXIntegration.cs +++ b/Runtime/Scripts/MobiledgeXIntegration.cs @@ -1,5 +1,5 @@ /** -* Copyright 2018-2021 MobiledgeX, Inc. All rights and licenses reserved. +* Copyright 2018-2022 MobiledgeX, Inc. All rights and licenses reserved. * MobiledgeX, Inc. 156 2nd Street #408, San Francisco, CA 94105 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -80,7 +80,6 @@ public partial class MobiledgeXIntegration : IDisposable AppPort latestAppPort = null; AppPort[] latestAppPortList = null; Location fallbackLocation = new Location(0, 0); - MelMessaging melMessaging; string region { @@ -121,11 +120,6 @@ public MobiledgeXIntegration(CarrierInfo carrierInfo = null, NetInterface netInt netInterface == null ? pIntegration.NetInterface : netInterface, uniqueId == null ? pIntegration.UniqueID : uniqueId, deviceInfo == null ? pIntegration.DeviceInfo : deviceInfo); - if (settings.MEL_ENABLED) - { - melMessaging = new MelMessaging(appName); - matchingEngine.SetMelMessaging(melMessaging); - } } /// @@ -142,11 +136,6 @@ public MobiledgeXIntegration(string orgName, string appName, string appVers, str pIntegration = new PlatformIntegration(); matchingEngine = new MatchingEngine(pIntegration.CarrierInfo, pIntegration.NetInterface, pIntegration.UniqueID, pIntegration.DeviceInfo); - if (settings.MEL_ENABLED) - { - melMessaging = new MelMessaging(appName); - matchingEngine.SetMelMessaging(melMessaging); - } } /// @@ -205,17 +194,17 @@ public async Task VerifyLocation(string dmeHost = null, uint dmePort = 0) // GPS and Tower Status: switch (reply.gps_location_status) { - case VerifyLocationReply.GPSLocationStatus.LOC_ROAMING_COUNTRY_MISMATCH: - case VerifyLocationReply.GPSLocationStatus.LOC_ERROR_UNAUTHORIZED: - case VerifyLocationReply.GPSLocationStatus.LOC_ERROR_OTHER: - case VerifyLocationReply.GPSLocationStatus.LOC_UNKNOWN: + case VerifyLocationReply.GPSLocationStatus.RoamingCountryMismatch: + case VerifyLocationReply.GPSLocationStatus.ErrorUnauthorized: + case VerifyLocationReply.GPSLocationStatus.ErrorOther: + case VerifyLocationReply.GPSLocationStatus.Unknown: return false; } switch (reply.tower_status) { - case VerifyLocationReply.TowerStatus.NOT_CONNECTED_TO_SPECIFIED_TOWER: - case VerifyLocationReply.TowerStatus.TOWER_UNKNOWN: + case VerifyLocationReply.TowerStatus.NotConnectedToSpecifiedTower: + case VerifyLocationReply.TowerStatus.TowerUnknown: return false; } diff --git a/Runtime/Scripts/MobiledgeXSettings.cs b/Runtime/Scripts/MobiledgeXSettings.cs index 21cc1e86..dbc1ba99 100644 --- a/Runtime/Scripts/MobiledgeXSettings.cs +++ b/Runtime/Scripts/MobiledgeXSettings.cs @@ -1,5 +1,5 @@ /** - * Copyright 2018-2021 MobiledgeX, Inc. All rights and licenses reserved. + * Copyright 2018-2022 MobiledgeX, Inc. All rights and licenses reserved. * MobiledgeX, Inc. 156 2nd Street #408, San Francisco, CA 94105 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,7 +29,5 @@ public class MobiledgeXSettings : ScriptableObject public string authPublicKey; public string region; public Logger.LogType logType = Logger.LogType.ErrorsAndWarnings; - [Tooltip("Set to true, If MEL mode is Enabled on your device.")] - public bool MEL_ENABLED; } } diff --git a/Tests/Runtime/MobiledgeX_RuntimeTests.cs b/Tests/Runtime/MobiledgeX_RuntimeTests.cs index 44d58859..110a23b6 100644 --- a/Tests/Runtime/MobiledgeX_RuntimeTests.cs +++ b/Tests/Runtime/MobiledgeX_RuntimeTests.cs @@ -1,5 +1,5 @@ /** -* Copyright 2018-2021 MobiledgeX, Inc. All rights and licenses reserved. +* Copyright 2018-2022 MobiledgeX, Inc. All rights and licenses reserved. * MobiledgeX, Inc. 156 2nd Street #408, San Francisco, CA 94105 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,23 +29,17 @@ namespace MobiledgeX public class MobiledgeX_RuntimeTests { MobiledgeXIntegration mxi; + string dmeHostOverride; + uint dmePortOverride; + #region Testing Setup [OneTimeSetUp] public void MobiledgeXEnvironmentSetup() { MobiledgeXIntegration.settings.region = "EU"; //For Testing Purposes, works in Editor only. - if (!UnityEditorInternal.InternalEditorUtility.isHumanControllingUs) - { - return; - } - if (!File.Exists(Path.Combine(Application.dataPath, "Plugins/MobiledgeX/iOS/PlatformIntegration.m")) && - !File.Exists(Path.Combine(Application.dataPath, "Plugins/MobiledgeX/link.xml")) && - !File.Exists(Path.Combine(Application.dataPath, "Plugins/MobiledgeX/MatchingEngineSDKRestLibrary.dll")) && - !File.Exists(Path.Combine(Application.dataPath, "Resources/MobiledgeXSettings.asset"))) - { - Assert.Fail("MobiledgeX Plugins are not loaded in the project, Can't perform tests"); - } + dmeHostOverride = "eu-stage.dme.mobiledgex.net"; + dmePortOverride = 38001; } #endregion @@ -53,7 +47,7 @@ public void MobiledgeXEnvironmentSetup() #region Run Time Tests [Test] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0")] + [TestCase("Ahmed-Org", "sdk-test", "9.0")] public void RegisterClient(string orgName, string appName, string appVers) { using (MobiledgeXIntegration mxi = new MobiledgeXIntegration(new CarrierInfoClass(), null, new UniqueIDClass(), new TestDeviceInfo())) @@ -70,7 +64,7 @@ public void RegisterClient(string orgName, string appName, string appVers) } [Test] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0")] + [TestCase("Ahmed-Org", "sdk-test", "9.0")] public void FindCloudlet(string orgName, string appName, string appVers) { using (MobiledgeXIntegration mxi = new MobiledgeXIntegration(new CarrierInfoClass(), null, new UniqueIDClass(), new TestDeviceInfo())) @@ -89,9 +83,9 @@ public void FindCloudlet(string orgName, string appName, string appVers) } [Test] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0", "http", 8085)] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0", "https", 2015)] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0", "tcp", 2016)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "http", 8085)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "https", 2015)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "tcp", 2016)] public void GetUrl(string orgName, string appName, string appVers, string proto, int port) { using (MobiledgeXIntegration mxi = new MobiledgeXIntegration(new CarrierInfoClass(), null, new UniqueIDClass(), new TestDeviceInfo())) @@ -110,7 +104,11 @@ public void GetUrl(string orgName, string appName, string appVers, string proto, } [Test] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0", "http", 8085)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "http", 8085)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "https", 2015)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "tcp", 2016)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "ws", 3765)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "udp", 2015)] public void GetHost(string orgName, string appName, string appVers, string proto, int port) { using (MobiledgeXIntegration mxi = new MobiledgeXIntegration(new CarrierInfoClass(), null, new UniqueIDClass(), new TestDeviceInfo())) @@ -161,7 +159,7 @@ public void RegisterClientFaliure(string orgName, string appName, string appVers } [Test] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0", 104.1954, 35.8617)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", 104.1954, 35.8617)] public void FindCloudletFaliure(string orgName, string appName, string appVers, double latitude, double longitude) { using (MobiledgeXIntegration mxi = new MobiledgeXIntegration(new CarrierInfoClass(), null, new UniqueIDClass(), new TestDeviceInfo())) @@ -197,7 +195,7 @@ public void FindCloudletFaliure(string orgName, string appName, string appVers, } [Test] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0", "ws", 3765, 2000)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", "ws", 3765, 2000)] public void WebSocketTest(string orgName, string appName, string appVers, string proto, int port, int timeOutMs) { using (MobiledgeXIntegration mxi = new MobiledgeXIntegration(new CarrierInfoClass(), null, new UniqueIDClass(), new TestDeviceInfo())) @@ -221,7 +219,7 @@ public void WebSocketTest(string orgName, string appName, string appVers, string [Test] - [TestCase("MobiledgeX-Samples", "sdktest", "9.0", 2000)] + [TestCase("Ahmed-Org", "sdk-test", "9.0", 2000)] public void UDPTest(string orgName, string appName, string appVers, int timeOutMs) { using (MobiledgeXIntegration mxi = new MobiledgeXIntegration(new CarrierInfoClass(), null, new UniqueIDClass(), new TestDeviceInfo())) @@ -232,7 +230,7 @@ public void UDPTest(string orgName, string appName, string appVers, int timeOutM var task = Task.Run(async () => { string hostName = await GetHostHelper(mxi, "udp"); - MobiledgeXUDPClient udpClient = new MobiledgeXUDPClient(hostName, mxi.GetAppPort(LProto.L_PROTO_UDP).public_port); + MobiledgeXUDPClient udpClient = new MobiledgeXUDPClient(hostName, mxi.GetAppPort(LProto.Udp).public_port); return UDPMessageHelper(udpClient, "ping", timeOutMs); }); Assert.True(task.Result == "pong"); @@ -245,14 +243,14 @@ public void UDPTest(string orgName, string appName, string appVers, int timeOutM public async Task RegisterHelper(MobiledgeXIntegration mxi) { - bool check = await mxi.Register(); + bool check = await mxi.Register(dmeHostOverride, dmePortOverride); await Task.Delay(TimeSpan.FromMilliseconds(1000)); return check; } public async Task FindCloudletHelper(MobiledgeXIntegration mxi) { - bool foundCloudlet = await mxi.FindCloudlet(); + bool foundCloudlet = await mxi.FindCloudlet(dmeHostOverride, dmePortOverride); await Task.Delay(TimeSpan.FromMilliseconds(1000)); return foundCloudlet; } @@ -278,14 +276,14 @@ public async Task GetUrlHelper(MobiledgeXIntegration mxi, string proto, switch (proto) { case "udp": - appPort = mxi.GetAppPort(LProto.L_PROTO_UDP, port); + appPort = mxi.GetAppPort(LProto.Udp, port); break; case "ws": case "wss": case "http": case "https": default: - appPort = mxi.GetAppPort(LProto.L_PROTO_TCP, port); + appPort = mxi.GetAppPort(LProto.Tcp, port); break; } @@ -318,14 +316,14 @@ public async Task GetHostHelper(MobiledgeXIntegration mxi, string proto, switch (proto) { case "udp": - appPort = mxi.GetAppPort(LProto.L_PROTO_UDP, port); + appPort = mxi.GetAppPort(LProto.Udp, port); break; case "ws": case "wss": case "http": case "https": default: - appPort = mxi.GetAppPort(LProto.L_PROTO_TCP, port); + appPort = mxi.GetAppPort(LProto.Tcp, port); break; } return mxi.GetHost(appPort);