Files
Ragon/Ragon.Server/Sources/RagonContext.cs
T

66 lines
1.9 KiB
C#
Raw Normal View History

2023-03-06 10:06:43 +04:00
/*
2024-05-19 12:26:42 +03:00
* Copyright 2023-2024 Eduard Kargin <kargin.eduard@gmail.com>
2023-03-06 10:06:43 +04:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2024-04-29 09:12:42 +03:00
using Ragon.Server.Data;
2023-04-09 10:52:18 +04:00
using Ragon.Server.IO;
using Ragon.Server.Lobby;
using Ragon.Server.Time;
using Ragon.Server.Room;
2023-03-06 10:06:43 +04:00
namespace Ragon.Server;
public class RagonContext
{
2023-04-09 10:52:18 +04:00
public ConnectionStatus ConnectionStatus { get; set; }
2023-04-13 20:42:05 +04:00
public INetworkConnection Connection { get; }
2023-03-06 10:06:43 +04:00
public IRagonLobby Lobby { get; private set; }
2023-04-09 10:52:18 +04:00
public RagonLobbyPlayer? LobbyPlayer { get; private set; }
public RagonRoom Room { get; private set; }
2023-03-06 10:06:43 +04:00
public RagonRoomPlayer? RoomPlayer { get; private set; }
2024-04-29 09:12:42 +03:00
public RagonData UserData { get; private set; }
2023-03-06 10:06:43 +04:00
public RagonScheduler Scheduler { get; private set; }
public int LimitBufferedEvents { get; private set; }
2023-04-09 10:52:18 +04:00
public RagonContext(
INetworkConnection connection,
IRagonLobby lobby,
RagonScheduler scheduler,
int limitBufferedEvents)
2023-03-06 10:06:43 +04:00
{
2023-04-09 10:52:18 +04:00
ConnectionStatus = ConnectionStatus.Unauthorized;
LimitBufferedEvents = limitBufferedEvents;
2023-03-06 10:06:43 +04:00
Connection = connection;
Lobby = lobby;
Scheduler = scheduler;
UserData = new RagonData();
2023-03-06 10:06:43 +04:00
}
2023-04-09 10:52:18 +04:00
internal void SetPlayer(RagonLobbyPlayer player)
{
LobbyPlayer = player;
}
2023-03-06 10:06:43 +04:00
internal void SetRoom(RagonRoom room, RagonRoomPlayer player)
{
2024-11-03 11:36:58 +03:00
Room?.DetachPlayer(player);
2023-03-06 10:06:43 +04:00
Room = room;
RoomPlayer = player;
2023-03-06 10:06:43 +04:00
Room.AttachPlayer(RoomPlayer);
}
}