Skip to content

Commit 607dc9a

Browse files
committed
trigger Client.OnClose and Room.OnLeave properly. closes #27
1 parent b303891 commit 607dc9a

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

Assets/ColyseusClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ IEnumerator Start () {
2020
String uri = "ws://" + serverName + ":" + port;
2121
client = new Client(uri);
2222
client.OnOpen += OnOpenHandler;
23+
client.OnClose += (object sender, EventArgs e) => Debug.Log ("CONNECTION CLOSED");
2324

2425
yield return StartCoroutine(client.Connect());
2526

Assets/Plugins/Colyseus/Client.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public Client (string endpoint, string id = null)
6969
}
7070

7171
this.connection = new Connection (this.endpoint.Uri);
72+
this.connection.OnClose += (object sender, EventArgs e) => this.OnClose.Invoke(sender, e);
7273
}
7374

7475
public IEnumerator Connect()

Assets/Plugins/Colyseus/Room.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public IEnumerator Connect ()
8282
public void SetConnection (Connection connection)
8383
{
8484
this.connection = connection;
85+
this.connection.OnClose += (object sender, EventArgs e) => this.OnLeave.Invoke(sender, e);
8586
this.OnReadyToConnect.Invoke (this, new EventArgs());
8687
}
8788

0 commit comments

Comments
 (0)