wired up the login screen to perform login(i think)

This commit is contained in:
alexiscatnip
2021-05-08 00:36:18 +08:00
parent b1771425eb
commit 249833b9a3
108 changed files with 3493 additions and 223 deletions
-107
View File
@@ -1,107 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LibreMetaverse;
using OpenMetaverse;
public class Globals : MonoBehaviour
{
//public static GridClient Client;
public string m_Path { get; private set; }
void Start()
{
//Client = new GridClient(); // instantiates the GridClient class
// to the global Client object
// Login to Simulator
//Client.Network.Login("FirstName", "LastName", "Password", "FirstBot", "1.0");
// Wait for a Keypress
//Console.ReadLine();
// Logout of simulator
//Client.Network.Logout();
////register events
//Client.Appearance.AgentWearablesReply += Appearance_AgentWearablesReply;
//Client.Appearance.AppearanceSet += Appearance_AppearanceSet;
//Client.Appearance.CachedBakesReply += Appearance_CachedBakesReply;
//Client.Appearance.RebakeAvatarRequested += Appearance_RebakeAvatarRequested;
////local chat
//Client.Self.ChatFromSimulator += Self_ChatFromSimulator;
////user connected/disconnected
//Client.Network.Disconnected += Network_Disconnected;
//Client.Network.LoginProgress += Network_LoginProgress;
////grid location update
//Client.Grid.CoarseLocationUpdate += Grid_CoarseLocationUpdate;
//Client.Network.SimChanged += Network_SimChanged;
//Get the path of the Game data folder
m_Path = Application.persistentDataPath;
//Output the Game data path to the console
Debug.Log("dataPath : " + m_Path);
var myCred = new Raindrop.Types.Credential();
myCred.User = "username69";
myCred.Pass = "password96";
var myRW = new Disk.ReadWrite();
myRW.saveCredentials(myCred,m_Path);
}
//private void Network_SimChanged(object sender, SimChangedEventArgs e)
//{
// throw new System.NotImplementedException();
//}
//private void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
//{
// throw new System.NotImplementedException();
//}
//private void Network_LoginProgress(object sender, LoginProgressEventArgs e)
//{
// throw new System.NotImplementedException();
//}
//private void Network_Disconnected(object sender, DisconnectedEventArgs e)
//{
// Debug.Log("Disconnected!");
//}
//private void Self_ChatFromSimulator(object sender, ChatEventArgs e)
//{
// throw new System.NotImplementedException();
//}
//private void Appearance_RebakeAvatarRequested(object sender, RebakeAvatarTexturesEventArgs e)
//{
// throw new System.NotImplementedException();
//}
//private void Appearance_CachedBakesReply(object sender, AgentCachedBakesReplyEventArgs e)
//{
// throw new System.NotImplementedException();
//}
//private void Appearance_AppearanceSet(object sender, AppearanceSetEventArgs e)
//{
// throw new System.NotImplementedException();
//}
//private void Appearance_AgentWearablesReply(object sender, AgentWearablesReplyEventArgs e)
//{
// throw new System.NotImplementedException();
//}
// Update is called once per frame
void Update()
{
}
}
-87
View File
@@ -1,87 +0,0 @@
using OpenMetaverse;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
using UnityWeld.Binding;
[Binding]
public class LoginVM : MonoBehaviour, INotifyPropertyChanged
{
private string username = "username";
private string password = "password";
[Binding]
public string Username
{
get
{
return username;
}
set
{
if (username == value)
{
return; // No change.
}
username = value;
OnPropertyChanged("username");
}
}
[Binding]
public string Password
{
get
{
return password;
}
set
{
if (password == value)
{
return; // No change.
}
password = value;
OnPropertyChanged("password");
}
}
/// <summary>
/// Event to raise when a property's value has changed.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
[Binding]
public void OnLoginBtnClick()
{
Debug.Log("loggin in TODO" + username + password);
GridClient Client = new GridClient();
}
}
@@ -0,0 +1,3 @@
{
"reference": "GUID:b6ef318018e211441b43da945a1caf13"
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e392e90217751074883ae145b1b472ef
AssemblyDefinitionReferenceImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
{
"name": "LibreMetaverseAssembly",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b6ef318018e211441b43da945a1caf13
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+3
View File
@@ -29,6 +29,7 @@ using System.Reflection;
using log4net;
using log4net.Appender;
using log4net.Config;
using UnityEngine;
[assembly: XmlConfigurator(Watch = true)]
@@ -117,6 +118,8 @@ namespace OpenMetaverse
/// <param name="exception">Exception that was raised</param>
public static void Log(object message, Helpers.LogLevel level, GridClient client, Exception exception)
{
Debug.Log(message);
if (client != null && client.Settings.LOG_NAMES)
message = $"<{client.Self.Name}>: {message}";
+5
View File
@@ -1104,6 +1104,7 @@ namespace OpenMetaverse
if (loginParams.Password == null)
loginParams.Password = string.Empty;
Logger.Log("pass: " + loginParams.Password, Helpers.LogLevel.Warning);
// Convert the password to MD5 if it isn't already
if (loginParams.Password.Length != 35 && !loginParams.Password.StartsWith("$1$"))
@@ -1171,6 +1172,9 @@ namespace OpenMetaverse
if (Client.Settings.USE_LLSD_LOGIN)
{
#region LLSD Based Login
Logger.Log("LLSD!", Helpers.LogLevel.Warning);
Logger.Log("first "+ loginParams.FirstName, Helpers.LogLevel.Warning);
Logger.Log("last "+ loginParams.LastName, Helpers.LogLevel.Warning);
// Create the CAPS login structure
OSDMap loginLLSD = new OSDMap
@@ -1231,6 +1235,7 @@ namespace OpenMetaverse
}
else
{
Logger.Log("XML-RPC!", Helpers.LogLevel.Warning);
#region XML-RPC Based Login Code
// Create the Hashtable for XmlRpcCs
+1 -1
View File
@@ -55,7 +55,7 @@ namespace OpenMetaverse
public static System.Net.IPAddress BIND_ADDR = System.Net.IPAddress.Any;
/// <summary>Use XML-RPC Login or LLSD Login, default is XML-RPC Login</summary>
public bool USE_LLSD_LOGIN = false;
public bool USE_LLSD_LOGIN = true;
/// <summary>
/// Maximum number of HTTP connections to open to a particular endpoint.
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 56e6f9fb60d030f40bbd45e53d23ceae
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ec40407118dfd3b4abf6f17a819b9f97
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,4 +1,5 @@
using System;
using SixLabors.ImageSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -7,13 +8,16 @@ using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
namespace Disk
namespace Raindrop.Disk
{
class ReadWrite
//contains functions that directly write to disk.
static class ReadWrite
{
public bool saveCredentials(Raindrop.Types.Credential cred, String path)
private static string filenameCredentials = "/SaveCredentials.data";
public static bool saveCredentials(Raindrop.Types.Credential cred, String path)
{
var dirPath = path + "/SaveCredentials.data";
var dirPath = path + filenameCredentials;
if (dirPath != null)
SaveSerialisable(ref cred, dirPath);
@@ -23,7 +27,7 @@ namespace Disk
}
//writes the obj/data to the filepath.
public void SaveSerialisable<T>(ref T data , String filePath)
public static void SaveSerialisable<T>(ref T data , String filePath)
{
FileStream dataStream = new FileStream(filePath, FileMode.Create);
@@ -33,7 +37,7 @@ namespace Disk
dataStream.Close();
}
public List<Raindrop.Types.Credential> readCredentials(String path)
public static List<Raindrop.Types.Credential> ReadCredentials(String path)
{
String dirPath = path + "/SaveCredentials.data";
@@ -52,7 +56,7 @@ namespace Disk
}
//reads filepath, returns the object of specified type
public object ReadSerialisable(String filePath)
public static object ReadSerialisable(String filePath)
{
FileStream dataStream = new FileStream(filePath, FileMode.Open);
@@ -72,5 +76,13 @@ namespace Disk
}
public static bool SaveTextureToFile(Image image)
{
//image.Save(outputStream, format);
return true;
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Raindrop.Disk
{
public static class SaveLoad
{
//return: TRUE for saving success.
public static bool saveCred(string user, string pass, string m_Path)
{
var myCred = new Raindrop.Types.Credential();
myCred.User = user;
myCred.Pass = pass;
if (Disk.ReadWrite.saveCredentials(myCred, m_Path) == true)
{
return true;
}
else
return false;
}
//return: the credentials as list
public static List<Raindrop.Types.Credential> loadCred(string m_Path)
{
var myCred = Disk.ReadWrite.ReadCredentials(m_Path);
return myCred;
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f14268f0af70b4642b1a0b816f2f8fd7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+183
View File
@@ -0,0 +1,183 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LibreMetaverse;
using OpenMetaverse;
namespace Raindrop
{
//implements (actually, composites) the gridclient
public class RaindropClient
{
//todo: internal eventbus for raindrop subsystems comms; include ui?
public event Notify LoginCompleted;
public event Notify LoginFailed;
public GridClient Client;
public enum RaindropState
{
intialise,
connected,
disconnected
}
private RaindropState clientstate;
private string Username { get; set; }
private string Password { get; set; }
public string configdatapath { get; private set; }
public RaindropClient()
{
clientstate = RaindropState.intialise;
Client = new GridClient(); // instantiates the GridClient class
// to the global Client object
Client.Settings.USE_LLSD_LOGIN = true;
const string AGNI_LOGIN_SERVER = "https://login.agni.lindenlab.com/cgi-bin/login.cgi";
Client.Settings.LOGIN_SERVER = AGNI_LOGIN_SERVER;
RegisterClientEvents();
}
private void RegisterClientEvents()
{
////register events
Client.Appearance.AgentWearablesReply += Appearance_AgentWearablesReply;
Client.Appearance.AppearanceSet += Appearance_AppearanceSet;
Client.Appearance.CachedBakesReply += Appearance_CachedBakesReply;
Client.Appearance.RebakeAvatarRequested += Appearance_RebakeAvatarRequested;
////local chat
Client.Self.ChatFromSimulator += Self_ChatFromSimulator;
////user connected/disconnected
Client.Network.Disconnected += Network_Disconnected;
Client.Network.LoginProgress += Network_LoginProgress;
////grid location update
Client.Grid.CoarseLocationUpdate += Grid_CoarseLocationUpdate;
Client.Network.SimChanged += Network_SimChanged;
}
internal void setConfigPath(string app_data_Path)
{
this.configdatapath = app_data_Path;
}
private void Network_SimChanged(object sender, SimChangedEventArgs e)
{
throw new System.NotImplementedException();
}
private void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
{
throw new System.NotImplementedException();
}
private void Network_LoginProgress(object sender, LoginProgressEventArgs e)
{
if (e.Status == LoginStatus.Failed)
{
LoginFailed?.Invoke(); //raise event.
Debug.LogWarning("logging in failed. \n Message: " + e.Message + "fail reason: " + e.FailReason);
}
else if (e.Status == LoginStatus.Success)
{
this.clientstate = RaindropState.connected;
LoginCompleted?.Invoke(); //raise event.
Disk.SaveLoad.saveCred(Username,Password, configdatapath);
Debug.Log("logging in success. \n Message: " + e.Message);
}
else if (e.Status == LoginStatus.ConnectingToLogin)
{
Debug.Log("ConnectingToLogin. \n Message: " + e.Message);
}
else
{
Debug.LogError("logging in not-supported. \n status type: " + e.Status.ToString() + "\n Message: " + e.Message);
}
}
private void Network_Disconnected(object sender, DisconnectedEventArgs e)
{
Debug.Log("Disconnected!");
}
private void Self_ChatFromSimulator(object sender, ChatEventArgs e)
{
throw new System.NotImplementedException();
}
private void Appearance_RebakeAvatarRequested(object sender, RebakeAvatarTexturesEventArgs e)
{
throw new System.NotImplementedException();
}
private void Appearance_CachedBakesReply(object sender, AgentCachedBakesReplyEventArgs e)
{
throw new System.NotImplementedException();
}
private void Appearance_AppearanceSet(object sender, AppearanceSetEventArgs e)
{
throw new System.NotImplementedException();
}
private void Appearance_AgentWearablesReply(object sender, AgentWearablesReplyEventArgs e)
{
throw new System.NotImplementedException();
}
//connects to SL. username is either format; ie: "firstname lastname" or "Jaken69" are both compaitble.
public void connectTo(string username, string password)
{
Username = username;
Password = password;
// Login to Simulator
string[] _splitname = username.Split();
if (_splitname.Length == 1)
{
var temp = _splitname[0];
_splitname = new string[2];
_splitname[0] = temp;
_splitname[1] = "";
}
else if (_splitname.Length != 2)
{
Debug.LogError("username is not 2 words (tip examples of valid usernames: \'Jake69 Resident\' or \'Jake Aabye\')");
return;
}
var lp = new LoginParams(Global.MainRaindropInstance.Client, _splitname[0], _splitname[1], password, "test", "0.1");
Debug.Log("attempt login with name1 " + _splitname[0] + " name 2 " + _splitname[1] + " password " + password);
Global.MainRaindropInstance.Client.Network.BeginLogin(lp);
//UnityClient.Client.Network.Login(lp);
// Logout of simulator
//Client.Network.Logout();
}
}
}
+16
View File
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Raindrop
{
public delegate void Notify();
class RaindropEvents
{
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4bd2bc82f97e97449b705c62f7b38954
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+1 -1
View File
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Raindrop
{
class Types
public class Types
{
[Serializable]
public class Credential
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 42d992bf1ac1bbb4890470b5056957ed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+25
View File
@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
public class Test_LibreMetaverse
{
// A Test behaves as an ordinary method
[Test]
public void Test_LibreMetaverseSimplePasses()
{
// Use the Assert class to test conditions
}
// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
// `yield return null;` to skip a frame.
[UnityTest]
public IEnumerator Test_LibreMetaverseWithEnumeratorPasses()
{
// Use the Assert class to test conditions.
// Use yield to skip a frame.
yield return null;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac824162184a168419902e9f5aec27eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+22
View File
@@ -0,0 +1,22 @@
{
"name": "Tests",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"LibreMetaverseAssembly"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e6683c01cea0f3647a5e6e64d7290bf1
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2cfae097021b49f4e8db6772f89117e4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+32
View File
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Raindrop;
public class Global : MonoBehaviour
{
//this static-new is like a globally accessible instance without a singleton! :)
public static RaindropClient MainRaindropInstance = new RaindropClient();
//this one manages the viewmodels and the stacking of UI modals.
public static RaindropViewManager RaindropVM = new RaindropViewManager();
public string app_data_Path { get; private set; }
private void Awake()
{
//initialise your 'statics'
//Get the path of the Game data folder
app_data_Path = Application.persistentDataPath;
//Output the Game data path to the console
Debug.Log("dataPath : " + app_data_Path);
MainRaindropInstance.setConfigPath(app_data_Path);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 55c6aede8bf73ca48b10f0d9e2e771f0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+69
View File
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Raindrop
{
public enum CanvasType
{
Login,
Game
}
public class RaindropViewManager
{
public CanvasManager cm;
//manages all child Viewmodels
public RaindropViewManager()
{
Debug.Log("VM manager setup ok");
//subscribe all events from raindropclient
Global.MainRaindropInstance.LoginCompleted += MainRaindropInstance_LoginCompleted;
Global.MainRaindropInstance.LoginFailed += MainRaindropInstance_LoginFailed;
}
//register the canvas manager which is in a GO, who has the responsibility of flipping pages.
public void registerWithRaindropClient(CanvasManager canvasManager)
{
cm = canvasManager;
//start up the initial login panel
pushLoginView();
}
private void pushLoginView()
{
cm.pushCanvas(CanvasType.Login);
}
private void MainRaindropInstance_LoginFailed()
{
showFailedLoginModal();
}
private void showFailedLoginModal()
{
throw new NotImplementedException();
}
private void MainRaindropInstance_LoginCompleted()
{
cm.popCanvas();
showSuccessLoginModal();
}
private void removeLoginView()
{
throw new NotImplementedException();
}
private void showSuccessLoginModal()
{
throw new NotImplementedException();
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b28c45eaa9e52bf44a89ae2585671419
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+52
View File
@@ -0,0 +1,52 @@
using UnityEngine;
public abstract class Singleton<T> : MonoBehaviour where T : Component
{
private static T instance;
private static bool m_applicationIsQuitting = false;
public static T GetInstance()
{
if (m_applicationIsQuitting) { return null; }
if (instance == null)
{
instance = FindObjectOfType<T>();
if (instance == null)
{
GameObject obj = new GameObject();
obj.name = typeof(T).Name;
instance = obj.AddComponent<T>();
}
}
return instance;
}
/* IMPORTANT!!! To use Awake in a derived class you need to do it this way
* protected override void Awake()
* {
* base.Awake();
* //Your code goes here
* }
* */
protected virtual void Awake()
{
if (instance == null)
{
instance = this as T;
DontDestroyOnLoad(gameObject);
}
else if (instance != this as T)
{
Destroy(gameObject);
}
else { DontDestroyOnLoad(gameObject); }
}
private void OnApplicationQuit()
{
m_applicationIsQuitting = true;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 973776a5b4c1d084bac0227a07fd79c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 00dae98274c946945baeeae92bee796e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
using Raindrop;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CanvasIdentifier : MonoBehaviour
{
public CanvasType canvasType;
}

Some files were not shown because too many files have changed in this diff Show More