Skip to content

Commit

Permalink
Initial Sharing Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Hodgson committed Jan 29, 2017
1 parent 15e7f1f commit 261802b
Show file tree
Hide file tree
Showing 88 changed files with 1,883 additions and 1,970 deletions.
35 changes: 19 additions & 16 deletions Assets/HoloToolkit/Sharing/Prefabs/Sharing.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 4: {fileID: 475158}
- 114: {fileID: 114000012667812730}
- 114: {fileID: 114000011012997360}
- 114: {fileID: 114000013602799446}
- component: {fileID: 475158}
- component: {fileID: 114000012667812730}
- component: {fileID: 114000013602799446}
- component: {fileID: 114332427252237600}
m_Layer: 0
m_Name: Sharing
m_TagString: Untagged
Expand Down Expand Up @@ -42,41 +42,44 @@ Prefab:
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 163528}
m_IsPrefabParent: 1
--- !u!114 &114000011012997360
--- !u!114 &114000012667812730
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 163528}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b9c87aaa636d31488ddd2b3e3fe29e3, type: 3}
m_Script: {fileID: 11500000, guid: 9af4ac91e9017f34c971bbf5e12948d3, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114000012667812730
ClientRole: 0
ServerAddress: localhost
ServerPort: 20602
connectOnAwake: 1
AutoDiscoverServer: 0
PingIntervalSec: 2
IsAudioEndpoint: 1
--- !u!114 &114000013602799446
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 163528}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9af4ac91e9017f34c971bbf5e12948d3, type: 3}
m_Script: {fileID: 11500000, guid: 8fa5da1314a4aa745a5be3f0f6ab6bd6, type: 3}
m_Name:
m_EditorClassIdentifier:
ClientRole: 0
ServerAddress: localhost
ServerPort: 20602
IsAudioEndpoint: 0
--- !u!114 &114000013602799446
SessionName: Default
--- !u!114 &114332427252237600
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 163528}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8fa5da1314a4aa745a5be3f0f6ab6bd6, type: 3}
m_Script: {fileID: 11500000, guid: c7a63ef1b98adec49bdb80fe1f187893, type: 3}
m_Name:
m_EditorClassIdentifier:
SessionName: Default
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using UnityEditor;
using UnityEngine;
using System.IO;
using HoloToolkit.Utilities;

namespace HoloToolkit.Sharing
{
Expand All @@ -21,7 +22,7 @@ public static void LaunchSessionServer()
return;
}

Utilities.ExternalProcess.FindAndLaunch(filePathName, @"-local");
ExternalProcess.FindAndLaunch(filePathName, @"-local");
}

[MenuItem("HoloToolkit/Sharing Service/Launch Session Manager", false, 101)]
Expand All @@ -36,7 +37,7 @@ public static void LaunchSessionUI()
return;
}

Utilities.ExternalProcess.FindAndLaunch(filePathName);
ExternalProcess.FindAndLaunch(filePathName);
}

[MenuItem("HoloToolkit/Sharing Service/Launch Profiler", false, 103)]
Expand All @@ -51,7 +52,7 @@ public static void LaunchProfilerX()
return;
}

Utilities.ExternalProcess.FindAndLaunch(filePathName);
ExternalProcess.FindAndLaunch(filePathName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace HoloToolkit.Sharing
{
[CustomEditor(typeof (SharingStage))]
[CustomEditor(typeof(SharingStage))]
public class SharingStageEditor : Editor
{
private Dictionary<object, bool> foldoutGUIMap = new Dictionary<object, bool>();
Expand All @@ -21,7 +21,7 @@ public override void OnInspectorGUI()

if (Application.isPlaying)
{
SharingStage networkManager = target as SharingStage;
SharingStage networkManager = (SharingStage)target;

SyncRoot root = networkManager.Root;

Expand All @@ -44,34 +44,34 @@ public override void OnInspectorGUI()

private void DrawDataModelGUI(SyncPrimitive syncPrimitive, string parentPath)
{
string name = syncPrimitive.FieldName;
object value = syncPrimitive.RawValue;
string fieldName = syncPrimitive.FieldName;
object rawValue = syncPrimitive.RawValue;

SyncObject SyncObject = syncPrimitive as SyncObject;
SyncObject syncObject = syncPrimitive as SyncObject;

if (SyncObject != null)
if (syncObject != null)
{
bool foldout = false;
if (foldoutGUIMap.ContainsKey(SyncObject))
if (foldoutGUIMap.ContainsKey(syncObject))
{
foldout = foldoutGUIMap[SyncObject];
foldout = foldoutGUIMap[syncObject];
}

int ownerId = SyncObject.OwnerId;
int ownerId = syncObject.OwnerId;
string owner = ownerId == int.MaxValue ? string.Empty : ownerId.ToString();
string objectType = SyncObject.ObjectType;
string objectType = syncObject.ObjectType;

foldout = EditorGUILayout.Foldout(foldout, string.Format("{0} (Owner:{1} Type:{2})", name, owner, objectType));
foldoutGUIMap[SyncObject] = foldout;
foldout = EditorGUILayout.Foldout(foldout, string.Format("{0} (Owner:{1} Type:{2})", fieldName, owner, objectType));
foldoutGUIMap[syncObject] = foldout;

if (foldout)
{
EditorGUI.indentLevel++;

SyncPrimitive[] children = SyncObject.GetChildren();
SyncPrimitive[] children = syncObject.GetChildren();
for (int i = 0; i < children.Length; i++)
{
DrawDataModelGUI(children[i], parentPath + "/" + name);
DrawDataModelGUI(children[i], parentPath + "/" + fieldName);
}

EditorGUI.indentLevel--;
Expand All @@ -80,13 +80,12 @@ private void DrawDataModelGUI(SyncPrimitive syncPrimitive, string parentPath)
else
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(name, GUILayout.MaxWidth(125));
EditorGUILayout.LabelField(value != null ? value.ToString() : "null", GUILayout.MaxWidth(200));
EditorGUILayout.LabelField(syncPrimitive.NetworkElement != null ? "live" : "local",
GUILayout.MaxWidth(50));
EditorGUILayout.LabelField(fieldName, GUILayout.MaxWidth(125));
EditorGUILayout.LabelField(rawValue != null ? rawValue.ToString() : "null", GUILayout.MaxWidth(200));
EditorGUILayout.LabelField(syncPrimitive.NetworkElement != null ? "live" : "local", GUILayout.MaxWidth(50));
if (syncPrimitive.NetworkElement != null)
{
EditorGUILayout.LabelField(parentPath + "/" + name, GUILayout.MaxWidth(500));
EditorGUILayout.LabelField(parentPath + "/" + fieldName, GUILayout.MaxWidth(500));
}

EditorGUILayout.EndHorizontal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HoloToolkit.Sharing
{
Expand Down
50 changes: 25 additions & 25 deletions Assets/HoloToolkit/Sharing/Scripts/ServerSessionsTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace HoloToolkit.Sharing
/// </summary>
public class ServerSessionsTracker : IDisposable
{
private bool disposed = false;
private bool disposed;
private SessionManager sessionManager;
private SessionManagerAdapter sessionManagerAdapter;

Expand All @@ -31,7 +31,7 @@ public class ServerSessionsTracker : IDisposable

public event Action ServerConnected;
public event Action ServerDisconnected;

/// <summary>
/// List of sessions on the server.
/// </summary>
Expand All @@ -49,17 +49,17 @@ public ServerSessionsTracker(SessionManager sessionMgr)

if (sessionManager != null)
{
this.sessionManagerAdapter = new SessionManagerAdapter();
sessionManager.AddListener(this.sessionManagerAdapter);
this.sessionManagerAdapter.ServerConnectedEvent += OnServerConnected;
this.sessionManagerAdapter.ServerDisconnectedEvent += OnServerDisconnected;
this.sessionManagerAdapter.SessionClosedEvent += OnSessionClosed;
this.sessionManagerAdapter.SessionAddedEvent += OnSessionAdded;
this.sessionManagerAdapter.CreateSucceededEvent += OnSessionCreatedSuccess;
this.sessionManagerAdapter.CreateFailedEvent += OnSessionCreatedFail;
this.sessionManagerAdapter.UserChangedEvent += OnUserChanged;
this.sessionManagerAdapter.UserJoinedSessionEvent += OnUserJoined;
this.sessionManagerAdapter.UserLeftSessionEvent += OnUserLeft;
sessionManagerAdapter = new SessionManagerAdapter();
sessionManager.AddListener(sessionManagerAdapter);
sessionManagerAdapter.ServerConnectedEvent += OnServerConnected;
sessionManagerAdapter.ServerDisconnectedEvent += OnServerDisconnected;
sessionManagerAdapter.SessionClosedEvent += OnSessionClosed;
sessionManagerAdapter.SessionAddedEvent += OnSessionAdded;
sessionManagerAdapter.CreateSucceededEvent += OnSessionCreatedSuccess;
sessionManagerAdapter.CreateFailedEvent += OnSessionCreatedFail;
sessionManagerAdapter.UserChangedEvent += OnUserChanged;
sessionManagerAdapter.UserJoinedSessionEvent += OnUserJoined;
sessionManagerAdapter.UserLeftSessionEvent += OnUserLeft;
}
}

Expand Down Expand Up @@ -214,19 +214,19 @@ protected virtual void Dispose(bool disposing)
{
OnServerDisconnected();

if (this.sessionManagerAdapter != null)
if (sessionManagerAdapter != null)
{
this.sessionManagerAdapter.ServerConnectedEvent -= OnServerConnected;
this.sessionManagerAdapter.ServerDisconnectedEvent -= OnServerDisconnected;
this.sessionManagerAdapter.SessionClosedEvent -= OnSessionClosed;
this.sessionManagerAdapter.SessionAddedEvent -= OnSessionAdded;
this.sessionManagerAdapter.CreateSucceededEvent -= OnSessionCreatedSuccess;
this.sessionManagerAdapter.CreateFailedEvent -= OnSessionCreatedFail;
this.sessionManagerAdapter.UserChangedEvent -= OnUserChanged;
this.sessionManagerAdapter.UserJoinedSessionEvent -= OnUserJoined;
this.sessionManagerAdapter.UserLeftSessionEvent -= OnUserLeft;
this.sessionManagerAdapter.Dispose();
this.sessionManagerAdapter = null;
sessionManagerAdapter.ServerConnectedEvent -= OnServerConnected;
sessionManagerAdapter.ServerDisconnectedEvent -= OnServerDisconnected;
sessionManagerAdapter.SessionClosedEvent -= OnSessionClosed;
sessionManagerAdapter.SessionAddedEvent -= OnSessionAdded;
sessionManagerAdapter.CreateSucceededEvent -= OnSessionCreatedSuccess;
sessionManagerAdapter.CreateFailedEvent -= OnSessionCreatedFail;
sessionManagerAdapter.UserChangedEvent -= OnUserChanged;
sessionManagerAdapter.UserJoinedSessionEvent -= OnUserJoined;
sessionManagerAdapter.UserLeftSessionEvent -= OnUserLeft;
sessionManagerAdapter.Dispose();
sessionManagerAdapter = null;
}

if (sessionManager != null)
Expand Down
Loading

0 comments on commit 261802b

Please sign in to comment.