Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions Assets/IRXRClient/Scripts/IRXRNetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public enum ServerPort {

public enum ClientPort {
Discovery = 7720,
Service = 7723,
Topic = 7724,
Service = 7730,
Topic = 7731,
}

class HostInfo {
public class HostInfo {
public string name;
public string ip;
public List<string> topics = new();
Expand All @@ -38,7 +38,7 @@ public class IRXRNetManager : Singleton<IRXRNetManager> {
public Action ConnectionSpin;
private UdpClient _discoveryClient;
private string _conncetionID = null;
private HostInfo _serverInfo = null;
public HostInfo _serverInfo = null;
private HostInfo _localInfo = new HostInfo();

private List<NetMQSocket> _sockets;
Expand Down Expand Up @@ -81,16 +81,16 @@ void Awake() {
// Default host name
if (PlayerPrefs.HasKey("HostName"))
{
// The key exists, proceed to get the value
string savedHostName = PlayerPrefs.GetString("HostName");
_localInfo.name = savedHostName;
Debug.Log($"Find Host Name: {_localInfo.name}");
// The key exists, proceed to get the value
string savedHostName = PlayerPrefs.GetString("HostName");
_localInfo.name = savedHostName;
Debug.Log($"Find Host Name: {_localInfo.name}");
}
else
{
// The key does not exist, handle it accordingly
_localInfo.name = "UnityClient";
Debug.Log($"Host Name not found, using default name {_localInfo.name}");
// The key does not exist, handle it accordingly
_localInfo.name = "UnityClient";
Debug.Log($"Host Name not found, using default name {_localInfo.name}");
}
}

Expand All @@ -101,7 +101,8 @@ void Start() {
OnConnectionStart += () => { isConnected = true; };
ConnectionSpin += () => {};
OnDisconnected += StopConnection;
RegisterServiceCallback("ChangeHostName", ChangeHoseName);
lastTimeStamp = -1.0f;
RegisterServiceCallback("ChangeHostName", ChangeHostName);
}

async void Update() {
Expand Down Expand Up @@ -231,6 +232,7 @@ public void ServiceRespondSpin() {
if (!_resSocket.HasIn) return;
string messageReceived = _resSocket.ReceiveFrameString();
string[] messageSplit = messageReceived.Split(":", 2);
Debug.Log($"Received service request {messageSplit[0]}");
if (_serviceCallbacks.ContainsKey(messageSplit[0])) {
string response = _serviceCallbacks[messageSplit[0]](messageSplit[1]);
_resSocket.SendFrame(response);
Expand Down Expand Up @@ -320,7 +322,7 @@ private static bool IsInSameSubnet(IPAddress ip1, IPAddress ip2, IPAddress subne
return true;
}

public string ChangeHoseName(string name) {
public string ChangeHostName(string name) {
_localInfo.name = name;
PlayerPrefs.SetString("HostName", name);
Debug.Log($"Change Host Name to {_localInfo.name}");
Expand All @@ -335,4 +337,8 @@ public bool CheckServerService(string serviceName) {
return false;
}

public HostInfo GetServerInfo() {
return _serverInfo;
}

}
29 changes: 7 additions & 22 deletions Assets/SceneLoader/Scripts/SimData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ public Vector3 GetScale() {
}

public class SimVisual {
// public string name;
public string type;
public string mesh;
public string material;
public SimMesh mesh;
public SimMaterial material;
public SimTransform trans;
public List<float> color;
}


Expand All @@ -51,41 +49,28 @@ public class SimAsset {
}

public class SimMesh : SimAsset {
public string dataHash;
public string hash;
public List<int> indicesLayout;

public List<int> verticesLayout;

public List<int> normalsLayout;

public List<int> uvLayout;

[JsonIgnore]
public Mesh compiledMesh;
}

public class SimMaterial : SimAsset {
public string dataHash;
public string hash;
public List<float> color;
public List<float> emissionColor;
public float specular;
public float shininess;
public float reflectance;
public string texture;
public List<float> textureSize;

[JsonIgnore]
public Material compiledMaterial;
public SimTexture texture;
}

public class SimTexture : SimAsset {
public string dataHash;
public string hash;
public int width;

public int height;

public string texureType;

[JsonIgnore]
public Texture compiledTexture;
public List<float> textureSize;
}
Loading