refactor: updated order of plugins callbacks
This commit is contained in:
@@ -34,9 +34,21 @@ public class RelayRoomPlugin: BaseRoomPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool OnPlayerJoined(RagonRoomPlayer player)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnPlayerLeaved(RagonRoomPlayer player)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool OnData(RagonRoomPlayer player, byte[] data)
|
public override bool OnData(RagonRoomPlayer player, byte[] data)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Data received");
|
Console.WriteLine("Data received");
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,9 +79,6 @@ public sealed class RoomCreateOperation : BaseOperation
|
|||||||
|
|
||||||
var roomPlugin = _serverPlugin.CreateRoomPlugin(information);
|
var roomPlugin = _serverPlugin.CreateRoomPlugin(information);
|
||||||
var room = new RagonRoom(roomId, information, roomPlugin);
|
var room = new RagonRoom(roomId, information, roomPlugin);
|
||||||
|
|
||||||
if (!roomPlugin.OnPlayerJoined(roomPlayer))
|
|
||||||
return;
|
|
||||||
|
|
||||||
roomPlayer.OnAttached(room);
|
roomPlayer.OnAttached(room);
|
||||||
|
|
||||||
@@ -95,6 +92,8 @@ public sealed class RoomCreateOperation : BaseOperation
|
|||||||
|
|
||||||
JoinSuccess(roomPlayer, room, Writer);
|
JoinSuccess(roomPlayer, room, Writer);
|
||||||
|
|
||||||
|
roomPlugin.OnPlayerJoined(roomPlayer);
|
||||||
|
|
||||||
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} joined to room {room.Id}");
|
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} joined to room {room.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,15 +48,14 @@ public sealed class RoomJoinOperation : BaseOperation
|
|||||||
|
|
||||||
var player = new RagonRoomPlayer(context, lobbyPlayer.Id, lobbyPlayer.Name);
|
var player = new RagonRoomPlayer(context, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||||
context.SetRoom(existsRoom, player);
|
context.SetRoom(existsRoom, player);
|
||||||
|
|
||||||
if (!existsRoom.Plugin.OnPlayerJoined(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_webHook.RoomJoined(context, existsRoom, player);
|
_webHook.RoomJoined(context, existsRoom, player);
|
||||||
|
|
||||||
JoinSuccess(context, existsRoom, Writer);
|
JoinSuccess(context, existsRoom, Writer);
|
||||||
|
|
||||||
existsRoom.RestoreBufferedEvents(player);
|
existsRoom.RestoreBufferedEvents(player);
|
||||||
|
|
||||||
|
existsRoom.Plugin.OnPlayerJoined(player);
|
||||||
|
|
||||||
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} joined to {existsRoom.Id}");
|
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} joined to {existsRoom.Id}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,6 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
{
|
{
|
||||||
var player = new RagonRoomPlayer(context, lobbyPlayer.Id, lobbyPlayer.Name);
|
var player = new RagonRoomPlayer(context, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||||
|
|
||||||
if (!existsRoom.Plugin.OnPlayerJoined(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
context.SetRoom(existsRoom, player);
|
context.SetRoom(existsRoom, player);
|
||||||
|
|
||||||
_ragonWebHookPlugin.RoomJoined(context, existsRoom, player);
|
_ragonWebHookPlugin.RoomJoined(context, existsRoom, player);
|
||||||
@@ -64,6 +61,8 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
JoinSuccess(player, existsRoom, Writer);
|
JoinSuccess(player, existsRoom, Writer);
|
||||||
|
|
||||||
existsRoom.RestoreBufferedEvents(player);
|
existsRoom.RestoreBufferedEvents(player);
|
||||||
|
|
||||||
|
existsRoom.Plugin.OnPlayerJoined(player);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -78,9 +77,6 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
var roomPlugin = _serverPlugin.CreateRoomPlugin(information);
|
var roomPlugin = _serverPlugin.CreateRoomPlugin(information);
|
||||||
var room = new RagonRoom(roomId, information, roomPlugin);
|
var room = new RagonRoom(roomId, information, roomPlugin);
|
||||||
|
|
||||||
if (!roomPlugin.OnPlayerJoined(roomPlayer))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_ragonWebHookPlugin.RoomCreated(context, room, roomPlayer);
|
_ragonWebHookPlugin.RoomCreated(context, room, roomPlayer);
|
||||||
|
|
||||||
context.Lobby.Persist(room);
|
context.Lobby.Persist(room);
|
||||||
@@ -90,6 +86,8 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} create room {room.Id} with scene {information.Scene}");
|
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} create room {room.Id} with scene {information.Scene}");
|
||||||
|
|
||||||
JoinSuccess(roomPlayer, room, Writer);
|
JoinSuccess(roomPlayer, room, Writer);
|
||||||
|
|
||||||
|
room.Plugin.OnPlayerJoined(roomPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user