@@ -94,8 +94,8 @@ public ColyseusSettings Settings
94
94
/// <param name="headers">Dictionary of headers to pass to the server when we create/join the room</param>
95
95
/// <typeparam name="T">Type of <see cref="ColyseusRoom{T}" /> we want to join or create</typeparam>
96
96
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
97
- public async Task < ColyseusRoom < T > > JoinOrCreate < T > ( string roomName , Dictionary < string , object > options = null ,
98
- Dictionary < string , string > headers = null )
97
+ public async Task < ColyseusRoom < T > > JoinOrCreate < T > ( string roomName , Dictionary < string , object > options = null , Dictionary < string , string > headers = null )
98
+ where T : Schema . Schema
99
99
{
100
100
return await CreateMatchMakeRequest < T > ( "joinOrCreate" , roomName , options , headers ) ;
101
101
}
@@ -108,8 +108,8 @@ public async Task<ColyseusRoom<T>> JoinOrCreate<T>(string roomName, Dictionary<s
108
108
/// <param name="headers">Dictionary of headers to pass to the server when we create the room</param>
109
109
/// <typeparam name="T">Type of <see cref="ColyseusRoom{T}" /> we want to create</typeparam>
110
110
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
111
- public async Task < ColyseusRoom < T > > Create < T > ( string roomName , Dictionary < string , object > options = null ,
112
- Dictionary < string , string > headers = null )
111
+ public async Task < ColyseusRoom < T > > Create < T > ( string roomName , Dictionary < string , object > options = null , Dictionary < string , string > headers = null )
112
+ where T : Schema . Schema
113
113
{
114
114
return await CreateMatchMakeRequest < T > ( "create" , roomName , options , headers ) ;
115
115
}
@@ -122,8 +122,8 @@ public async Task<ColyseusRoom<T>> Create<T>(string roomName, Dictionary<string,
122
122
/// <param name="headers">Dictionary of headers to pass to the server when we join the room</param>
123
123
/// <typeparam name="T">Type of <see cref="ColyseusRoom{T}" /> we want to join</typeparam>
124
124
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
125
- public async Task < ColyseusRoom < T > > Join < T > ( string roomName , Dictionary < string , object > options = null ,
126
- Dictionary < string , string > headers = null )
125
+ public async Task < ColyseusRoom < T > > Join < T > ( string roomName , Dictionary < string , object > options = null , Dictionary < string , string > headers = null )
126
+ where T : Schema . Schema
127
127
{
128
128
return await CreateMatchMakeRequest < T > ( "join" , roomName , options , headers ) ;
129
129
}
@@ -136,8 +136,8 @@ public async Task<ColyseusRoom<T>> Join<T>(string roomName, Dictionary<string, o
136
136
/// <param name="headers">Dictionary of headers to pass to the server when we join the room</param>
137
137
/// <typeparam name="T">Type of <see cref="ColyseusRoom{T}" /> we want to join</typeparam>
138
138
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
139
- public async Task < ColyseusRoom < T > > JoinById < T > ( string roomId , Dictionary < string , object > options = null ,
140
- Dictionary < string , string > headers = null )
139
+ public async Task < ColyseusRoom < T > > JoinById < T > ( string roomId , Dictionary < string , object > options = null , Dictionary < string , string > headers = null )
140
+ where T : Schema . Schema
141
141
{
142
142
return await CreateMatchMakeRequest < T > ( "joinById" , roomId , options , headers ) ;
143
143
}
@@ -149,8 +149,8 @@ public async Task<ColyseusRoom<T>> JoinById<T>(string roomId, Dictionary<string,
149
149
/// <param name="headers">Dictionary of headers to pass to the server when we reconnect to the room</param>
150
150
/// <typeparam name="T">Type of <see cref="ColyseusRoom{T}" /> we want to reconnect with</typeparam>
151
151
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
152
- public async Task < ColyseusRoom < T > > Reconnect < T > ( ReconnectionToken reconnectionToken ,
153
- Dictionary < string , string > headers = null )
152
+ public async Task < ColyseusRoom < T > > Reconnect < T > ( ReconnectionToken reconnectionToken , Dictionary < string , string > headers = null )
153
+ where T : Schema . Schema
154
154
{
155
155
Dictionary < string , object > options = new Dictionary < string , object > ( ) ;
156
156
options . Add ( "reconnectionToken" , reconnectionToken . Token ) ;
@@ -167,11 +167,9 @@ public async Task<ColyseusRoom<T>> Reconnect<T>(ReconnectionToken reconnectionTo
167
167
/// <param name="options">Dictionary of options to pass to the room upon creation/joining</param>
168
168
/// <param name="headers">Dictionary of headers to pass to the server when we create/join the room</param>
169
169
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
170
- public async Task < ColyseusRoom < dynamic > > JoinOrCreate ( string roomName ,
171
- Dictionary < string , object > options = null ,
172
- Dictionary < string , string > headers = null )
170
+ public async Task < ColyseusRoom < NoState > > JoinOrCreate ( string roomName , Dictionary < string , object > options = null , Dictionary < string , string > headers = null )
173
171
{
174
- return await CreateMatchMakeRequest < dynamic > ( "joinOrCreate" , roomName , options , headers ) ;
172
+ return await CreateMatchMakeRequest < NoState > ( "joinOrCreate" , roomName , options , headers ) ;
175
173
}
176
174
177
175
/// <summary>
@@ -181,10 +179,10 @@ public async Task<ColyseusRoom<dynamic>> JoinOrCreate(string roomName,
181
179
/// <param name="options">Dictionary of options to pass to the room upon creation</param>
182
180
/// <param name="headers">Dictionary of headers to pass to the server when we create the room</param>
183
181
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
184
- public async Task < ColyseusRoom < dynamic > > Create ( string roomName , Dictionary < string , object > options = null ,
182
+ public async Task < ColyseusRoom < NoState > > Create ( string roomName , Dictionary < string , object > options = null ,
185
183
Dictionary < string , string > headers = null )
186
184
{
187
- return await CreateMatchMakeRequest < dynamic > ( "create" , roomName , options , headers ) ;
185
+ return await CreateMatchMakeRequest < NoState > ( "create" , roomName , options , headers ) ;
188
186
}
189
187
190
188
/// <summary>
@@ -194,10 +192,10 @@ public async Task<ColyseusRoom<dynamic>> Create(string roomName, Dictionary<stri
194
192
/// <param name="options">Dictionary of options to pass to the room upon joining</param>
195
193
/// <param name="headers">Dictionary of headers to pass to the server when we join the room</param>
196
194
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
197
- public async Task < ColyseusRoom < dynamic > > Join ( string roomName , Dictionary < string , object > options = null ,
195
+ public async Task < ColyseusRoom < NoState > > Join ( string roomName , Dictionary < string , object > options = null ,
198
196
Dictionary < string , string > headers = null )
199
197
{
200
- return await CreateMatchMakeRequest < dynamic > ( "join" , roomName , options , headers ) ;
198
+ return await CreateMatchMakeRequest < NoState > ( "join" , roomName , options , headers ) ;
201
199
}
202
200
203
201
/// <summary>
@@ -207,10 +205,10 @@ public async Task<ColyseusRoom<dynamic>> Join(string roomName, Dictionary<string
207
205
/// <param name="options">Dictionary of options to pass to the room upon joining</param>
208
206
/// <param name="headers">Dictionary of headers to pass to the server when we join the room</param>
209
207
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
210
- public async Task < ColyseusRoom < dynamic > > JoinById ( string roomId , Dictionary < string , object > options = null ,
208
+ public async Task < ColyseusRoom < NoState > > JoinById ( string roomId , Dictionary < string , object > options = null ,
211
209
Dictionary < string , string > headers = null )
212
210
{
213
- return await CreateMatchMakeRequest < dynamic > ( "joinById" , roomId , options , headers ) ;
211
+ return await CreateMatchMakeRequest < NoState > ( "joinById" , roomId , options , headers ) ;
214
212
}
215
213
216
214
/// <summary>
@@ -220,41 +218,12 @@ public async Task<ColyseusRoom<dynamic>> JoinById(string roomId, Dictionary<stri
220
218
/// <param name="sessionId">Previously connected sessionId</param>
221
219
/// <param name="headers">Dictionary of headers to pass to the server when we reconnect to the room</param>
222
220
/// <returns><see cref="ColyseusRoom{T}" /> via async task</returns>
223
- public async Task < ColyseusRoom < dynamic > > Reconnect ( string roomId , string sessionId ,
221
+ public async Task < ColyseusRoom < NoState > > Reconnect ( string roomId , string sessionId ,
224
222
Dictionary < string , string > headers = null )
225
223
{
226
224
Dictionary < string , object > options = new Dictionary < string , object > ( ) ;
227
225
options . Add ( "sessionId" , sessionId ) ;
228
- return await CreateMatchMakeRequest < dynamic > ( "joinById" , roomId , options , headers ) ;
229
- }
230
-
231
- /// <summary>
232
- /// Get all available rooms
233
- /// </summary>
234
- /// <param name="roomName">Room identifier</param>
235
- /// <param name="headers">Dictionary of headers to pass to the server</param>
236
- /// <returns><see cref="ColyseusRoomAvailable" /> array via async task</returns>
237
- public async Task < ColyseusRoomAvailable [ ] > GetAvailableRooms ( string roomName = "" )
238
- {
239
- return await GetAvailableRooms < ColyseusRoomAvailable > ( roomName ) ;
240
- }
241
-
242
- /// <summary>
243
- /// Get all available rooms with provided custom type <typeparamref name="T" />
244
- /// </summary>
245
- /// <param name="roomName">Name of the room</param>
246
- /// <returns><see cref="CSACSARoomAvailableCollection{T}" /> array via async task</returns>
247
- public async Task < T [ ] > GetAvailableRooms < T > ( string roomName = "" )
248
- {
249
- string json = await Http . Request ( "GET" , $ "matchmake/{ roomName } ") ;
250
-
251
- if ( json . StartsWith ( "[" , StringComparison . CurrentCulture ) )
252
- {
253
- json = "{\" rooms\" :" + json + "}" ;
254
- }
255
-
256
- CSARoomAvailableCollection < T > response = JsonUtility . FromJson < CSARoomAvailableCollection < T > > ( json ) ;
257
- return response . rooms ;
226
+ return await CreateMatchMakeRequest < NoState > ( "joinById" , roomId , options , headers ) ;
258
227
}
259
228
260
229
/// <summary>
@@ -265,17 +234,19 @@ public async Task<T[]> GetAvailableRooms<T>(string roomName = "")
265
234
/// <param name="previousRoom">Previous ColyseusRoom{T} instance to re-establish the server connection: Please do not use this devMode param for general purposes</param>
266
235
/// <typeparam name="T">Type of <see cref="ColyseusRoom{T}" /> we're consuming the seat from</typeparam>
267
236
/// <returns><see cref="ColyseusRoom{T}" /> in which we now have a seat via async task</returns>
268
- public async Task < ColyseusRoom < T > > ConsumeSeatReservation < T > ( ColyseusMatchMakeResponse response ,
269
- Dictionary < string , string > headers = null , ColyseusRoom < T > previousRoom = null )
237
+ public async Task < ColyseusRoom < T > > ConsumeSeatReservation < T > ( ColyseusMatchMakeResponse response , Dictionary < string , string > headers = null , ColyseusRoom < T > previousRoom = null )
238
+ where T : Schema . Schema
270
239
{
271
240
ColyseusRoom < T > room = new ColyseusRoom < T > ( response . room . name )
272
241
{
273
242
RoomId = response . room . roomId ,
274
243
SessionId = response . sessionId
275
244
} ;
276
245
277
- Dictionary < string , object > queryString = new Dictionary < string , object > ( ) ;
278
- queryString . Add ( "sessionId" , room . SessionId ) ;
246
+ Dictionary < string , object > queryString = new Dictionary < string , object >
247
+ {
248
+ { "sessionId" , room . SessionId }
249
+ } ;
279
250
280
251
// forward reconnection token
281
252
if ( response . reconnectionToken != null )
@@ -361,8 +332,8 @@ void OnJoin()
361
332
/// <returns><see cref="ColyseusRoom{T}" /> we have matched with via async task</returns>
362
333
/// <exception cref="Exception">Thrown if there is a network related error</exception>
363
334
/// <exception cref="MatchMakeException">Thrown if there is an error in the match making process on the server side</exception>
364
- protected async Task < ColyseusRoom < T > > CreateMatchMakeRequest < T > ( string method , string roomName ,
365
- Dictionary < string , object > options , Dictionary < string , string > headers )
335
+ protected async Task < ColyseusRoom < T > > CreateMatchMakeRequest < T > ( string method , string roomName , Dictionary < string , object > options , Dictionary < string , string > headers )
336
+ where T : Schema . Schema
366
337
{
367
338
if ( options == null )
368
339
{
0 commit comments