Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/meta quest3 merge #6

Merged
merged 13 commits into from
Jul 30, 2024
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,7 @@ crashlytics-build.properties

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
/[Aa]ssets/[Ss]treamingAssets/aa/*

# macOS
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -209,13 +208,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
serializedVersion: 2
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &963194225
GameObject:
Expand Down Expand Up @@ -301,13 +300,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1212994459
GameObject:
Expand All @@ -319,8 +318,10 @@ GameObject:
m_Component:
- component: {fileID: 1212994461}
- component: {fileID: 1212994460}
- component: {fileID: 1212994462}
- component: {fileID: 1212994463}
m_Layer: 0
m_Name: GameObject
m_Name: IRXRClient
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand All @@ -335,7 +336,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1212994459}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4a6d688e54fab9443ab110c5d418edb5, type: 3}
m_Script: {fileID: 11500000, guid: 6ea543980d7f8014582c156390e33b5a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1212994461
Expand All @@ -345,11 +346,102 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1212994459}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1212994462
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1212994459}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b271b8ad6710f58479bebd7de90dbb75, type: 3}
m_Name:
m_EditorClassIdentifier:
isServiceConnected: 0
--- !u!114 &1212994463
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1212994459}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e83446e454ea134418d53860b41fa803, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1905412432
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1905412433}
- component: {fileID: 1905412434}
- component: {fileID: 1905412435}
m_Layer: 0
m_Name: SimScene
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1905412433
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1905412432}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.3197056, y: 0.22981061, z: -1.8257755}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1905412434
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1905412432}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f25e002b6045cf2c1b5bcda5d4b0dd28, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1905412435
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1905412432}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 43b973fe0a32ff894963acb23af7fd0e, type: 3}
m_Name:
m_EditorClassIdentifier:
_trans: {fileID: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 963194228}
- {fileID: 705507995}
- {fileID: 1212994461}
- {fileID: 1905412433}
34 changes: 0 additions & 34 deletions Assets/IRXRClient/Scripts/ConnectionController.cs

This file was deleted.

68 changes: 0 additions & 68 deletions Assets/IRXRClient/Scripts/Discovery.cs

This file was deleted.

108 changes: 108 additions & 0 deletions Assets/IRXRClient/Scripts/IRXRNetManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

using NetMQ;
using NetMQ.Sockets;
using UnityEngine;
using System;
using System.Net;
using System.Text;
using Newtonsoft.Json;
using System.Net.Sockets;
using System.Collections.Generic;


public class IRXRNetManager : Singleton<IRXRNetManager> {

// public delegate void DiscoveryEventHandler();
public Action OnDiscoveryCompleted;
public Action OnNewServerDiscovered;
private string _id = null;
private string _serverIP;

private UdpClient _discoveryClient;

private Dictionary<string, string> _informations;

private List<NetMQSocket> _sockets;

private SubscriberSocket _subSocket;
private PublisherSocket _pubSocket;
private RequestSocket _reqSocket;
private ResponseSocket _resSocket;

void Awake() {
AsyncIO.ForceDotNet.Force();
_discoveryClient = new UdpClient(7720);
_sockets = new List<NetMQSocket>();
_reqSocket = new RequestSocket();
_resSocket = new ResponseSocket();
_subSocket = new SubscriberSocket();
_pubSocket = new PublisherSocket();
_pubSocket.Bind("tcp://*:7723");
_sockets = new List<NetMQSocket> { _reqSocket, _resSocket, _subSocket, _pubSocket };
}

void Start() {
OnNewServerDiscovered += () => Debug.Log("New Server Discovered");
OnDiscoveryCompleted += () => { };
}

void Update()
{
if (_discoveryClient.Available == 0) return; // there's no message to read
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
byte[] result = _discoveryClient.Receive(ref endPoint);
string message = Encoding.UTF8.GetString(result);

if (!message.StartsWith("SimPub")) return; // not the right tag

var split = message.Split(":", 3);

if (split[1] != _id){
OnNewServerDiscovered.Invoke();
_id = split[1];
string info = split[2];
_informations = JsonConvert.DeserializeObject<Dictionary<string, string>>(info);
_serverIP = endPoint.Address.ToString();
OnDiscoveryCompleted.Invoke();
}
}

void OnApplicationQuit() {
_discoveryClient.Dispose();
foreach (var socket in _sockets) {
socket.Dispose();
}
// This must be called after all the NetMQ sockets are disposed
NetMQConfig.Cleanup();
}

public bool HasDiscovered() {
return _serverIP != null;
}

public string GetServerIp() {
return _serverIP;
}

public int GetServerPort(string service) {
int.TryParse(_informations[service], out int result);
return result;
}

public SubscriberSocket GetSubscriberSocket() {
return _subSocket;
}

public RequestSocket GetRequestSocket() {
return _reqSocket;
}

public PublisherSocket GetPublisherSocket() {
return _pubSocket;
}

public ResponseSocket GetResponseSocket() {
return _resSocket;
}

}
Loading