Skip to content

Commit 1e28a1b

Browse files
committed
NoneSerializer<NoState>: fix matchmaking into rooms without state. bump version
1 parent dc9c2c8 commit 1e28a1b

File tree

5 files changed

+19
-24
lines changed

5 files changed

+19
-24
lines changed

Assets/Colyseus/Runtime/Colyseus/Room/ColyseusRoom.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using GameDevWare.Serialization;
88
using NativeWebSocket;
99
using UnityEngine;
10-
using Type = System.Type;
1110

1211
namespace Colyseus
1312
{
@@ -406,16 +405,7 @@ protected async void ParseMessage(byte[] bytes)
406405
}
407406
else
408407
{
409-
try
410-
{
411-
Serializer = (IColyseusSerializer<T>) new NoneSerializer<NoState>();
412-
}
413-
catch (Exception e)
414-
{
415-
DisplaySerializerErrorHelp(e,
416-
"Consider setting state in the server-side using \"this.setState(new " + typeof(T).Name +
417-
"())\"");
418-
}
408+
Serializer = (IColyseusSerializer<T>) new NoneSerializer();
419409
}
420410

421411
if (bytes.Length > offset)

Assets/Colyseus/Runtime/Colyseus/Serializer/NoneSerializer.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ public class NoState : Schema.Schema { }
66
/// <summary>
77
/// An empty implementation of <see cref="IColyseusSerializer{T}" />
88
/// </summary>
9-
public class NoneSerializer<T> : IColyseusSerializer<object> where T: NoState
9+
public class NoneSerializer : IColyseusSerializer<NoState>
1010
{
11+
NoState state = new NoState();
12+
1113
/// <inheritdoc />
1214
public void SetState(byte[] rawEncodedState, int offset)
1315
{
1416
}
1517

1618
/// <inheritdoc />
17-
public object GetState()
19+
public NoState GetState()
1820
{
19-
return this;
21+
return state;
2022
}
2123

2224
/// <inheritdoc />

Assets/Colyseus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "io.colyseus.sdk",
3-
"version": "0.16.3",
3+
"version": "0.16.4",
44
"displayName": "Colyseus SDK",
55
"description": "Colyseus Multiplayer SDK for Unity",
66
"unity": "2019.1",

Server/package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"tsx": "tsx watch src/index.ts",
1010
"loadtest": "tsx loadtest/example.ts --room my_room --numClients 99",
1111
"build": "tsc",
12-
"test": "mocha -r tsx ts-node/register test/**_test.ts --exit --timeout 15000"
12+
"test": "mocha -r tsx ts-node/register test/**_test.ts --exit --timeout 15000",
13+
"schema-codegen": "schema-codegen src/rooms/schema/* --csharp --output ../Assets/Example/"
1314
},
1415
"author": "",
1516
"license": "UNLICENSED",
@@ -18,9 +19,9 @@
1819
},
1920
"homepage": "https://github.com/colyseus/create-colyseus#readme",
2021
"devDependencies": {
21-
"@colyseus/loadtest": "^0.16.0-preview.0",
22-
"@colyseus/playground": "^0.16.0-preview.0",
23-
"@colyseus/testing": "^0.16.0-preview.0",
22+
"@colyseus/loadtest": "^0.16.0",
23+
"@colyseus/playground": "^0.16.0",
24+
"@colyseus/testing": "^0.16.0",
2425
"@types/cors": "^2.8.6",
2526
"@types/express": "^4.17.1",
2627
"@types/mocha": "^8.2.3",
@@ -30,11 +31,11 @@
3031
"typescript": "^5.0.4"
3132
},
3233
"dependencies": {
33-
"@colyseus/auth": "^0.16.0-preview.0",
34-
"@colyseus/core": "^0.16.0-preview.0",
35-
"@colyseus/monitor": "^0.16.0-preview.0",
36-
"@colyseus/tools": "^0.16.0-preview.0",
37-
"colyseus": "^0.16.0-preview.0",
34+
"@colyseus/auth": "^0.16.0",
35+
"@colyseus/core": "^0.16.0",
36+
"@colyseus/monitor": "^0.16.0",
37+
"@colyseus/tools": "^0.16.0",
38+
"colyseus": "^0.16.0",
3839
"cors": "^2.8.5",
3940
"express": "^4.16.4"
4041
}

Server/src/app.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { playground } from "@colyseus/playground";
1212
*/
1313
import { MyRoom } from "./rooms/MyRoom";
1414
import auth from "./config/auth";
15+
import { LobbyRoom } from "colyseus";
1516

1617
export default config({
1718
options: {
@@ -28,6 +29,7 @@ export default config({
2829
*/
2930
gameServer.define('my_room', MyRoom);
3031

32+
gameServer.define('lobby', LobbyRoom);
3133
},
3234

3335
initializeExpress: (app) => {

0 commit comments

Comments
 (0)