Skip to content

Commit 9bd99d1

Browse files
Alex DreneaAlex Drenea
authored andcommitted
minor fixes in SharingStage.
1 parent f5fd4bc commit 9bd99d1

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Assets/HoloToolkit/Sharing/Scripts/SharingStage.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class SharingStage : MonoBehaviour
3232

3333
public bool AutoDiscoverServer = false;
3434

35+
[Tooltip("Determines how often the discovery service should ping the network in search of a server.")]
36+
public float PingIntervalSec = 2;
37+
3538
/// <summary>
3639
/// Pipes XTools console output to Unity's output window for debugging
3740
/// </summary>
@@ -44,13 +47,10 @@ public class SharingStage : MonoBehaviour
4447
/// <summary>
4548
/// Provides callbacks when server is discovered or lost.
4649
/// </summary>
47-
private DiscoveryClientAdapter listener;
48-
/// <summary>
49-
/// Determines how often the discovery service should ping the network in search of a server.
50-
/// </summary>
51-
public float PingIntervalSec = 2;
52-
private float PingIntervalCurrent = 0;
53-
private bool IsTryingToFindServer = false;
50+
private DiscoveryClientAdapter discoveryClientAdapter;
51+
52+
private float pingIntervalCurrent = 0;
53+
private bool isTryingToFindServer = false;
5454

5555
private void Awake()
5656
{
@@ -74,14 +74,14 @@ protected void OnDestroy()
7474

7575
if (this.discoveryClient != null)
7676
{
77-
discoveryClient.RemoveListener(listener);
77+
discoveryClient.RemoveListener(discoveryClientAdapter);
7878
discoveryClient.Dispose();
7979
discoveryClient = null;
8080

81-
if (listener != null)
81+
if (discoveryClientAdapter != null)
8282
{
83-
listener.Dispose();
84-
listener = null;
83+
discoveryClientAdapter.Dispose();
84+
discoveryClientAdapter = null;
8585
}
8686
}
8787

@@ -101,7 +101,7 @@ protected void OnDestroy()
101101

102102
private void LateUpdate()
103103
{
104-
if (this.IsTryingToFindServer)
104+
if (this.isTryingToFindServer)
105105
{
106106
AutoDiscoverUpdate();
107107
}
@@ -156,23 +156,23 @@ private void SendConnectedNotification()
156156

157157
private void AutoDiscoverInit()
158158
{
159-
listener = new DiscoveryClientAdapter();
160-
listener.DiscoveredEvent += OnSystemDiscovered;
159+
discoveryClientAdapter = new DiscoveryClientAdapter();
160+
discoveryClientAdapter.DiscoveredEvent += OnSystemDiscovered;
161161

162162
discoveryClient = DiscoveryClient.Create();
163-
discoveryClient.AddListener(listener);
163+
discoveryClient.AddListener(discoveryClientAdapter);
164164

165165
//Start Finding Server
166-
IsTryingToFindServer = true;
166+
isTryingToFindServer = true;
167167
}
168168

169169
private void AutoDiscoverUpdate()
170170
{
171171
//Searching Enabled-> Update DiscoveryClient to check results, Wait Interval then Ping network.
172-
PingIntervalCurrent += Time.deltaTime;
173-
if (PingIntervalCurrent > PingIntervalSec)
172+
pingIntervalCurrent += Time.deltaTime;
173+
if (pingIntervalCurrent > PingIntervalSec)
174174
{
175-
PingIntervalCurrent = 0;
175+
pingIntervalCurrent = 0;
176176
discoveryClient.Ping();
177177
}
178178
discoveryClient.Update();
@@ -183,7 +183,7 @@ private void OnSystemDiscovered(DiscoveredSystem obj)
183183
if (obj.GetRole() == SystemRole.SessionDiscoveryServerRole)
184184
{
185185
//Found a server. Stop pinging the network and connect
186-
IsTryingToFindServer = false;
186+
isTryingToFindServer = false;
187187
this.ServerAddress = obj.GetAddress();
188188
Debug.Log("System Discovered at: " + this.ServerAddress);
189189
Connect();

0 commit comments

Comments
 (0)