aha
This commit is contained in:
71
Assets/Mirror/Hosting/Edgegap/Enums/ApiEnvironment.cs
Normal file
71
Assets/Mirror/Hosting/Edgegap/Enums/ApiEnvironment.cs
Normal file
@ -0,0 +1,71 @@
|
||||
namespace Edgegap
|
||||
{
|
||||
public enum ApiEnvironment
|
||||
{
|
||||
Staging,
|
||||
Console,
|
||||
}
|
||||
|
||||
public static class ApiEnvironmentsExtensions
|
||||
{
|
||||
public static string GetApiUrl(this ApiEnvironment apiEnvironment)
|
||||
{
|
||||
string apiUrl;
|
||||
|
||||
switch (apiEnvironment)
|
||||
{
|
||||
case ApiEnvironment.Staging:
|
||||
apiUrl = "https://staging-api.edgegap.com";
|
||||
break;
|
||||
case ApiEnvironment.Console:
|
||||
apiUrl = "https://api.edgegap.com";
|
||||
break;
|
||||
default:
|
||||
apiUrl = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return apiUrl;
|
||||
}
|
||||
|
||||
public static string GetDashboardUrl(this ApiEnvironment apiEnvironment)
|
||||
{
|
||||
string apiUrl;
|
||||
|
||||
switch (apiEnvironment)
|
||||
{
|
||||
case ApiEnvironment.Staging:
|
||||
apiUrl = "https://staging-console.edgegap.com";
|
||||
break;
|
||||
case ApiEnvironment.Console:
|
||||
apiUrl = "https://console.edgegap.com";
|
||||
break;
|
||||
default:
|
||||
apiUrl = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return apiUrl;
|
||||
}
|
||||
|
||||
public static string GetDocumentationUrl(this ApiEnvironment apiEnvironment)
|
||||
{
|
||||
string apiUrl;
|
||||
|
||||
switch (apiEnvironment)
|
||||
{
|
||||
case ApiEnvironment.Staging:
|
||||
apiUrl = "https://staging-docs.edgegap.com/docs/category/unity";
|
||||
break;
|
||||
case ApiEnvironment.Console:
|
||||
apiUrl = "https://docs.edgegap.com/docs/category/unity";
|
||||
break;
|
||||
default:
|
||||
apiUrl = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return apiUrl;
|
||||
}
|
||||
}
|
||||
}
|
18
Assets/Mirror/Hosting/Edgegap/Enums/ApiEnvironment.cs.meta
Normal file
18
Assets/Mirror/Hosting/Edgegap/Enums/ApiEnvironment.cs.meta
Normal file
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd1ad4f631934cc42b0bc025483f7ffc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Hosting/Edgegap/Enums/ApiEnvironment.cs
|
||||
uploadId: 736421
|
84
Assets/Mirror/Hosting/Edgegap/Enums/ServerStatus.cs
Normal file
84
Assets/Mirror/Hosting/Edgegap/Enums/ServerStatus.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using IO.Swagger.Model;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Edgegap
|
||||
{
|
||||
public enum ServerStatus
|
||||
{
|
||||
NA, // Not an actual Edgegap server status. Indicates that there are no active server.
|
||||
Initializing,
|
||||
Seeking,
|
||||
Deploying,
|
||||
Ready,
|
||||
Seeked,
|
||||
Terminated,
|
||||
Scanning,
|
||||
Terminating,
|
||||
Error,
|
||||
}
|
||||
|
||||
public static class ServerStatusExtensions
|
||||
{
|
||||
private static string GetServerStatusLabel(this Status serverStatusResponse) => char.ToUpper(serverStatusResponse.CurrentStatus[7]) + serverStatusResponse.CurrentStatus.Substring(8).ToLower();
|
||||
|
||||
public static ServerStatus GetServerStatus(this Status serverStatusResponse)
|
||||
{
|
||||
ServerStatus serverStatus;
|
||||
|
||||
try
|
||||
{
|
||||
serverStatus = (ServerStatus)Enum.Parse(typeof(ServerStatus), serverStatusResponse.GetServerStatusLabel());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Debug.LogError($"Got unexpected server status: {serverStatusResponse.CurrentStatus}. Considering the deployment to be terminated.");
|
||||
serverStatus = ServerStatus.Terminated;
|
||||
}
|
||||
|
||||
return serverStatus;
|
||||
}
|
||||
|
||||
public static string GetStatusBgClass(this ServerStatus serverStatus)
|
||||
{
|
||||
string statusBgClass;
|
||||
|
||||
switch (serverStatus)
|
||||
{
|
||||
case ServerStatus.NA:
|
||||
case ServerStatus.Terminated:
|
||||
statusBgClass = "bg--secondary"; break;
|
||||
case ServerStatus.Ready:
|
||||
statusBgClass = "bg--success"; break;
|
||||
case ServerStatus.Error:
|
||||
statusBgClass = "bg--danger"; break;
|
||||
default:
|
||||
statusBgClass = "bg--warning"; break;
|
||||
}
|
||||
|
||||
return statusBgClass;
|
||||
}
|
||||
|
||||
public static string GetLabelText(this ServerStatus serverStatus)
|
||||
{
|
||||
string statusLabel;
|
||||
|
||||
if (serverStatus == ServerStatus.NA)
|
||||
{
|
||||
statusLabel = "N/A";
|
||||
}
|
||||
else
|
||||
{
|
||||
statusLabel = Enum.GetName(typeof(ServerStatus), serverStatus);
|
||||
}
|
||||
|
||||
return statusLabel;
|
||||
}
|
||||
|
||||
public static bool IsOneOf(this ServerStatus serverStatus, params ServerStatus[] serverStatusOptions)
|
||||
{
|
||||
return serverStatusOptions.Contains(serverStatus);
|
||||
}
|
||||
}
|
||||
}
|
18
Assets/Mirror/Hosting/Edgegap/Enums/ServerStatus.cs.meta
Normal file
18
Assets/Mirror/Hosting/Edgegap/Enums/ServerStatus.cs.meta
Normal file
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 880f675359f40d24e99109ad46894688
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Hosting/Edgegap/Enums/ServerStatus.cs
|
||||
uploadId: 736421
|
46
Assets/Mirror/Hosting/Edgegap/Enums/ToolState.cs
Normal file
46
Assets/Mirror/Hosting/Edgegap/Enums/ToolState.cs
Normal file
@ -0,0 +1,46 @@
|
||||
namespace Edgegap
|
||||
{
|
||||
public enum ToolState
|
||||
{
|
||||
Disconnected,
|
||||
Connecting,
|
||||
Connected, // Waiting for a deployment
|
||||
Building,
|
||||
Pushing,
|
||||
ProcessingDeployment,
|
||||
DeploymentRunning,
|
||||
}
|
||||
|
||||
public static class PluginStateExtensions
|
||||
{
|
||||
public static bool CanConnect(this ToolState currentState)
|
||||
{
|
||||
return currentState == ToolState.Disconnected;
|
||||
}
|
||||
|
||||
public static bool CanDisconnect(this ToolState currentState)
|
||||
{
|
||||
return currentState == ToolState.Connected;
|
||||
}
|
||||
|
||||
public static bool CanStartDeployment(this ToolState currentState)
|
||||
{
|
||||
return currentState == ToolState.Connected;
|
||||
}
|
||||
|
||||
public static bool CanStopDeployment(this ToolState currentState)
|
||||
{
|
||||
return currentState == ToolState.DeploymentRunning;
|
||||
}
|
||||
|
||||
public static bool CanEditConnectionInfo(this ToolState currentState)
|
||||
{
|
||||
return currentState.CanConnect();
|
||||
}
|
||||
|
||||
public static bool HasActiveDeployment(this ToolState currentState)
|
||||
{
|
||||
return currentState == ToolState.ProcessingDeployment || currentState == ToolState.DeploymentRunning;
|
||||
}
|
||||
}
|
||||
}
|
18
Assets/Mirror/Hosting/Edgegap/Enums/ToolState.cs.meta
Normal file
18
Assets/Mirror/Hosting/Edgegap/Enums/ToolState.cs.meta
Normal file
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6d6b357e2b245e4fb9758d8175a6554
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Hosting/Edgegap/Enums/ToolState.cs
|
||||
uploadId: 736421
|
Reference in New Issue
Block a user