Skip to content

Commit

Permalink
rename DeltaContainer to StateContainer. rename room.data to room.state
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Mar 29, 2018
1 parent d0c52ae commit 3a49a23
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Assets/Plugins/Colyseus/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RoomAvailable {

/// <summary>
/// </summary>
public class Room : DeltaContainer
public class Room : StateContainer
{
public string id;
public string name;
Expand Down Expand Up @@ -204,7 +204,7 @@ protected void Patch (byte[] delta)
this.Set(newState);

if (this.OnStateChange != null)
this.OnStateChange.Invoke(this, new RoomUpdateEventArgs(this.data));
this.OnStateChange.Invoke(this, new RoomUpdateEventArgs(this.state));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public struct Listener<T>
public string[] rawRules;
}

public class DeltaContainer
public class StateContainer
{
public IndexedDictionary<string, object> data;
public IndexedDictionary<string, object> state;
private List<PatchListener> listeners;
private FallbackPatchListener defaultListener;

Expand All @@ -40,17 +40,17 @@ public class DeltaContainer
{ ":*", new Regex(@"(.*)") },
};

public DeltaContainer (IndexedDictionary<string, object> data)
public StateContainer (IndexedDictionary<string, object> state)
{
this.data = data;
this.state = state;
this.Reset();
}

public PatchObject[] Set(IndexedDictionary<string, object> newData) {
var patches = Compare.GetPatchList(this.data, newData);
var patches = Compare.GetPatchList(this.state, newData);

this.CheckPatches(patches);
this.data = newData;
this.state = newData;

return patches;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/ClientComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ClientComponent : MonoBehaviour

// Use this for initialization
public IEnumerator Start () {
client = new Client("ws://localhost:3553");
client = new Client("ws://localhost:8080");

yield return StartCoroutine(client.Connect());

Expand Down
4 changes: 2 additions & 2 deletions Assets/Tests/RoomTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public IEnumerator TestConnection()
};

component.room.OnStateChange += (object sender, RoomUpdateEventArgs e) => {
Assert.NotNull (component.room.data ["players"]);
Assert.NotNull (component.room.data ["messages"]);
Assert.NotNull (component.room.state ["players"]);
Assert.NotNull (component.room.state ["messages"]);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
using Colyseus;
using GameDevWare.Serialization;

public class DeltaContainerTest {
DeltaContainer container;
public class StateContainerTest {
StateContainer container;

[SetUp]
public void Init () {
container = new DeltaContainer (GetRawData());
container = new StateContainer (GetRawData());
}

[TearDown]
Expand Down Expand Up @@ -192,7 +192,7 @@ public void ListenRemoveArray() {

[Test]
public void ListenInitialState() {
var container = new DeltaContainer (new IndexedDictionary<string, object>());
var container = new StateContainer (new IndexedDictionary<string, object>());
var listenCalls = 0;

container.Listen ("players/:id/position/:attribute", (DataChange change) => {
Expand Down
Binary file modified ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file modified ProjectSettings/ProjectSettings.asset
Binary file not shown.

0 comments on commit 3a49a23

Please sign in to comment.