Skip to content

Commit b12fed5

Browse files
Getting it a bit closer to the Sharing Stage Connection refactor...
1 parent 97fc82d commit b12fed5

File tree

4 files changed

+136
-155
lines changed

4 files changed

+136
-155
lines changed

Assets/HoloToolkit-Tests/Sharing/Scenes/SharingTest.unity

Lines changed: 100 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -402,106 +402,6 @@ Prefab:
402402
m_RemovedComponents: []
403403
m_ParentPrefab: {fileID: 100100000, guid: a611e772ef8ddf64d8106a9cbb70f31c, type: 2}
404404
m_IsPrefabParent: 0
405-
--- !u!1001 &731017293
406-
Prefab:
407-
m_ObjectHideFlags: 0
408-
serializedVersion: 2
409-
m_Modification:
410-
m_TransformParent: {fileID: 0}
411-
m_Modifications:
412-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
413-
type: 2}
414-
propertyPath: m_LocalPosition.x
415-
value: 0
416-
objectReference: {fileID: 0}
417-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
418-
type: 2}
419-
propertyPath: m_LocalPosition.y
420-
value: 0
421-
objectReference: {fileID: 0}
422-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
423-
type: 2}
424-
propertyPath: m_LocalPosition.z
425-
value: 1.5
426-
objectReference: {fileID: 0}
427-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
428-
type: 2}
429-
propertyPath: m_LocalRotation.x
430-
value: -0
431-
objectReference: {fileID: 0}
432-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
433-
type: 2}
434-
propertyPath: m_LocalRotation.y
435-
value: -0
436-
objectReference: {fileID: 0}
437-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
438-
type: 2}
439-
propertyPath: m_LocalRotation.z
440-
value: -0
441-
objectReference: {fileID: 0}
442-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
443-
type: 2}
444-
propertyPath: m_LocalRotation.w
445-
value: 1
446-
objectReference: {fileID: 0}
447-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
448-
type: 2}
449-
propertyPath: m_RootOrder
450-
value: 4
451-
objectReference: {fileID: 0}
452-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
453-
type: 2}
454-
propertyPath: m_AnchoredPosition.x
455-
value: 0
456-
objectReference: {fileID: 0}
457-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
458-
type: 2}
459-
propertyPath: m_AnchoredPosition.y
460-
value: 0
461-
objectReference: {fileID: 0}
462-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
463-
type: 2}
464-
propertyPath: m_SizeDelta.x
465-
value: 320
466-
objectReference: {fileID: 0}
467-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
468-
type: 2}
469-
propertyPath: m_SizeDelta.y
470-
value: 320
471-
objectReference: {fileID: 0}
472-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
473-
type: 2}
474-
propertyPath: m_AnchorMin.x
475-
value: 0
476-
objectReference: {fileID: 0}
477-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
478-
type: 2}
479-
propertyPath: m_AnchorMin.y
480-
value: 0
481-
objectReference: {fileID: 0}
482-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
483-
type: 2}
484-
propertyPath: m_AnchorMax.x
485-
value: 0
486-
objectReference: {fileID: 0}
487-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
488-
type: 2}
489-
propertyPath: m_AnchorMax.y
490-
value: 0
491-
objectReference: {fileID: 0}
492-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
493-
type: 2}
494-
propertyPath: m_Pivot.x
495-
value: 0.5
496-
objectReference: {fileID: 0}
497-
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
498-
type: 2}
499-
propertyPath: m_Pivot.y
500-
value: 0.5
501-
objectReference: {fileID: 0}
502-
m_RemovedComponents: []
503-
m_ParentPrefab: {fileID: 100100000, guid: 9a2f56337670a294baaf9bba300b1c1c, type: 2}
504-
m_IsPrefabParent: 0
505405
--- !u!102 &754146363 stripped
506406
TextMesh:
507407
m_PrefabParentObject: {fileID: 102277783203209222, guid: 16014d77e332f484388b5872987a2c02,
@@ -633,6 +533,106 @@ MonoBehaviour:
633533
Transform:
634534
m_PrefabParentObject: {fileID: 475158, guid: 8aaf37823b26ee449bb3b3d7775965c3, type: 2}
635535
m_PrefabInternal: {fileID: 1703234099}
536+
--- !u!1001 &1004402896
537+
Prefab:
538+
m_ObjectHideFlags: 0
539+
serializedVersion: 2
540+
m_Modification:
541+
m_TransformParent: {fileID: 0}
542+
m_Modifications:
543+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
544+
type: 2}
545+
propertyPath: m_LocalPosition.x
546+
value: 0
547+
objectReference: {fileID: 0}
548+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
549+
type: 2}
550+
propertyPath: m_LocalPosition.y
551+
value: 0
552+
objectReference: {fileID: 0}
553+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
554+
type: 2}
555+
propertyPath: m_LocalPosition.z
556+
value: 1.5
557+
objectReference: {fileID: 0}
558+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
559+
type: 2}
560+
propertyPath: m_LocalRotation.x
561+
value: -0
562+
objectReference: {fileID: 0}
563+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
564+
type: 2}
565+
propertyPath: m_LocalRotation.y
566+
value: -0
567+
objectReference: {fileID: 0}
568+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
569+
type: 2}
570+
propertyPath: m_LocalRotation.z
571+
value: -0
572+
objectReference: {fileID: 0}
573+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
574+
type: 2}
575+
propertyPath: m_LocalRotation.w
576+
value: 1
577+
objectReference: {fileID: 0}
578+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
579+
type: 2}
580+
propertyPath: m_RootOrder
581+
value: 4
582+
objectReference: {fileID: 0}
583+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
584+
type: 2}
585+
propertyPath: m_AnchoredPosition.x
586+
value: 0
587+
objectReference: {fileID: 0}
588+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
589+
type: 2}
590+
propertyPath: m_AnchoredPosition.y
591+
value: 0
592+
objectReference: {fileID: 0}
593+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
594+
type: 2}
595+
propertyPath: m_SizeDelta.x
596+
value: 320
597+
objectReference: {fileID: 0}
598+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
599+
type: 2}
600+
propertyPath: m_SizeDelta.y
601+
value: 320
602+
objectReference: {fileID: 0}
603+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
604+
type: 2}
605+
propertyPath: m_AnchorMin.x
606+
value: 0
607+
objectReference: {fileID: 0}
608+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
609+
type: 2}
610+
propertyPath: m_AnchorMin.y
611+
value: 0
612+
objectReference: {fileID: 0}
613+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
614+
type: 2}
615+
propertyPath: m_AnchorMax.x
616+
value: 0
617+
objectReference: {fileID: 0}
618+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
619+
type: 2}
620+
propertyPath: m_AnchorMax.y
621+
value: 0
622+
objectReference: {fileID: 0}
623+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
624+
type: 2}
625+
propertyPath: m_Pivot.x
626+
value: 0.5
627+
objectReference: {fileID: 0}
628+
- target: {fileID: 224469518390730572, guid: 9a2f56337670a294baaf9bba300b1c1c,
629+
type: 2}
630+
propertyPath: m_Pivot.y
631+
value: 0.5
632+
objectReference: {fileID: 0}
633+
m_RemovedComponents: []
634+
m_ParentPrefab: {fileID: 100100000, guid: 9a2f56337670a294baaf9bba300b1c1c, type: 2}
635+
m_IsPrefabParent: 0
636636
--- !u!1001 &1703234099
637637
Prefab:
638638
m_ObjectHideFlags: 0

Assets/HoloToolkit/Sharing/Prefabs/ManualIpConfigUtility.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ MonoBehaviour:
10031003
m_GameObject: {fileID: 1315177525143494}
10041004
m_Enabled: 1
10051005
m_EditorHideFlags: 0
1006-
m_Script: {fileID: 11500000, guid: 1dc603e0d201da746b38b8ce2e4ae7a6, type: 3}
1006+
m_Script: {fileID: 11500000, guid: d529249adad35084bbde52a834d075cd, type: 3}
10071007
m_Name:
10081008
m_EditorClassIdentifier:
10091009
HideWhenConnected: 1
@@ -1563,6 +1563,7 @@ MonoBehaviour:
15631563
m_Name:
15641564
m_EditorClassIdentifier:
15651565
PivotAxis: 0
1566+
TargetTransform: {fileID: 0}
15661567
--- !u!114 &114522924503171464
15671568
MonoBehaviour:
15681569
m_ObjectHideFlags: 1

Assets/HoloToolkit/Sharing/Scripts/SharingStage.cs

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -150,42 +150,25 @@ public string UserName
150150
}
151151

152152
private NetworkConnectionAdapter networkConnectionAdapter;
153-
private NetworkConnection networkConnection;
154153
public NetworkConnection Connection
155154
{
156-
get
157-
{
158-
if (networkConnection == null && Manager != null)
159-
{
160-
networkConnection = Manager.GetServerConnection();
161-
}
162-
return networkConnection;
163-
}
155+
get { return Manager != null ? Manager.GetServerConnection() : null; }
164156
}
165157

166158
/// <summary>
167159
/// Returns true if connected to a Sharing Service server.
168160
/// </summary>
169161
public bool IsConnected
170162
{
171-
get
172-
{
173-
if (Manager != null && Connection != null)
174-
{
175-
return Connection.IsConnected();
176-
}
177-
178-
return false;
179-
}
163+
get { return Manager != null && Connection != null && Connection.IsConnected(); }
180164
}
181165

182166
protected override void Awake()
183167
{
184168
base.Awake();
185169

186170
AppInstanceUniqueId = Guid.NewGuid().ToString();
187-
logWriter = new ConsoleLogWriter();
188-
logWriter.ShowDetailedLogs = ShowDetailedLogs;
171+
logWriter = new ConsoleLogWriter { ShowDetailedLogs = ShowDetailedLogs };
189172

190173
if (AutoDiscoverServer)
191174
{
@@ -197,6 +180,30 @@ protected override void Awake()
197180
}
198181
}
199182

183+
private void OnEnable()
184+
{
185+
Application.logMessageReceived += HandleLog;
186+
}
187+
188+
private void LateUpdate()
189+
{
190+
if (isTryingToFindServer)
191+
{
192+
AutoDiscoverUpdate();
193+
}
194+
195+
if (Manager != null)
196+
{
197+
// Update the XToolsManager to processes any network messages that have arrived
198+
Manager.Update();
199+
}
200+
}
201+
202+
private void OnDisable()
203+
{
204+
Application.logMessageReceived -= HandleLog;
205+
}
206+
200207
protected override void OnDestroy()
201208
{
202209
if (discoveryClient != null)
@@ -232,11 +239,10 @@ protected override void OnDestroy()
232239
SessionsTracker = null;
233240
}
234241

235-
if (networkConnection != null)
242+
if (Connection != null)
236243
{
237-
networkConnection.RemoveListener((byte)MessageID.StatusOnly, networkConnectionAdapter);
238-
networkConnection.Dispose();
239-
networkConnection = null;
244+
Connection.RemoveListener((byte)MessageID.StatusOnly, networkConnectionAdapter);
245+
Connection.Dispose();
240246

241247
if (networkConnectionAdapter != null)
242248
{
@@ -257,20 +263,6 @@ protected override void OnDestroy()
257263
base.OnDestroy();
258264
}
259265

260-
private void LateUpdate()
261-
{
262-
if (isTryingToFindServer)
263-
{
264-
AutoDiscoverUpdate();
265-
}
266-
267-
if (Manager != null)
268-
{
269-
// Update the XToolsManager to processes any network messages that have arrived
270-
Manager.Update();
271-
}
272-
}
273-
274266
private void Connect()
275267
{
276268
var config = new ClientConfig(ClientRole);
@@ -287,11 +279,10 @@ private void Connect()
287279
Manager = SharingManager.Create(config);
288280

289281
//set up callbacks so that we know when we've connected successfully
290-
networkConnection = Manager.GetServerConnection();
291282
networkConnectionAdapter = new NetworkConnectionAdapter();
292283
networkConnectionAdapter.ConnectedCallback += NetworkConnectionAdapter_ConnectedCallback;
293284
networkConnectionAdapter.DisconnectedCallback += NetworkConnectionAdapter_ConnectedCallback;
294-
networkConnection.AddListener((byte)MessageID.StatusOnly, networkConnectionAdapter);
285+
Connection.AddListener((byte)MessageID.StatusOnly, networkConnectionAdapter);
295286

296287
SyncStateListener = new SyncStateListener();
297288
Manager.RegisterSyncListener(SyncStateListener);
@@ -411,16 +402,6 @@ public void ConnectToServer()
411402
Manager.SetServerConnectionInfo(ServerAddress, (uint)ServerPort);
412403
}
413404

414-
private void OnEnable()
415-
{
416-
Application.logMessageReceived += HandleLog;
417-
}
418-
419-
private void OnDisable()
420-
{
421-
Application.logMessageReceived -= HandleLog;
422-
}
423-
424405
private void HandleLog(string logString, string stackTrace, LogType type)
425406
{
426407
switch (type)

0 commit comments

Comments
 (0)