AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SyncLong.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 namespace HoloToolkit.Sharing.SyncModel
5 {
10  public class SyncLong : SyncPrimitive
11  {
12  private LongElement element;
13  private long value;
14 
15 #if UNITY_EDITOR
16  public override object RawValue
17  {
18  get { return value; }
19  }
20 #endif
21 
22  public long Value
23  {
24  get { return value; }
25 
26  set
27  {
28  // Has the value actually changed?
29  if (this.value != value)
30  {
31  // Change the value
32  this.value = value;
33 
34  if (element != null)
35  {
36  // Notify network that the value has changed
37  element.SetValue(value);
38  }
39  }
40  }
41  }
42 
43  public SyncLong(string field)
44  : base(field)
45  {
46  }
47 
48  public override void InitializeLocal(ObjectElement parentElement)
49  {
50  element = parentElement.CreateLongElement(XStringFieldName, value);
51  NetworkElement = element;
52  }
53 
54  public void AddFromLocal(ObjectElement parentElement, long localValue)
55  {
56  InitializeLocal(parentElement);
57  Value = localValue;
58  }
59 
60  public override void AddFromRemote(Element remoteElement)
61  {
62  NetworkElement = remoteElement;
63  element = LongElement.Cast(remoteElement);
64  value = element.GetValue();
65  }
66 
67  public override void UpdateFromRemote(long remoteValue)
68  {
69  value = remoteValue;
70  }
71  }
72 }
override void InitializeLocal(ObjectElement parentElement)
Initializes this object for local use. Doesn't wait for network initialization.
Definition: SyncLong.cs:48
void AddFromLocal(ObjectElement parentElement, long localValue)
Definition: SyncLong.cs:54
This class implements the long primitive for the syncing system. It does the heavy lifting to make ad...
Definition: SyncLong.cs:10
override void UpdateFromRemote(long remoteValue)
Called when the primitive value has changed from a remote action.
Definition: SyncLong.cs:67
virtual LongElement CreateLongElement(XString name, long value)
Base primitive used to define an element within the data model. The primitive is defined by a field a...
override void AddFromRemote(Element remoteElement)
Called when being remotely initialized.
Definition: SyncLong.cs:60
virtual void SetValue(long newValue)
Definition: LongElement.cs:53
static LongElement Cast(Element element)
Definition: LongElement.cs:42