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

66 lines
1.8 KiB
C#
Raw Permalink Normal View History

2023-03-06 10:06:43 +04:00
/*
* Copyright 2023 Eduard Kargin <kargin.eduard@gmail.com>
*
* 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.
*/
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 IExecutor Executor { get; private set; }
public IRagonLobby Lobby { get; private set; }
2023-04-09 10:52:18 +04:00
public RagonLobbyPlayer? LobbyPlayer { get; private set; }
2023-03-06 10:06:43 +04:00
public RagonRoom? Room { get; private set; }
public RagonRoomPlayer? RoomPlayer { get; private set; }
public RagonScheduler Scheduler { get; private set; }
2023-04-09 10:52:18 +04:00
public RagonContext(
INetworkConnection connection,
IExecutor executor,
IRagonLobby lobby,
RagonScheduler scheduler)
2023-03-06 10:06:43 +04:00
{
2023-04-09 10:52:18 +04:00
ConnectionStatus = ConnectionStatus.Unauthorized;
2023-03-06 10:06:43 +04:00
Connection = connection;
Executor = executor;
Lobby = lobby;
Scheduler = scheduler;
}
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)
{
Room?.DetachPlayer(RoomPlayer);
Room = room;
RoomPlayer = player;
Room.AttachPlayer(RoomPlayer);
}
}