mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-05-13 04:59:35 +08:00
parent
5f80e5934b
commit
832b99dcdc
@ -4,6 +4,7 @@ using Milimoe.FunGame.Core.Api.Utility;
|
|||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
using Milimoe.FunGame.Core.Interface.Base;
|
using Milimoe.FunGame.Core.Interface.Base;
|
||||||
using Milimoe.FunGame.Core.Library.Common.Addon;
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.SQLScript.Common;
|
using Milimoe.FunGame.Core.Library.SQLScript.Common;
|
||||||
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
|
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
|
||||||
@ -219,13 +220,27 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
if (requestData.Count >= 1)
|
if (requestData.Count >= 1)
|
||||||
{
|
{
|
||||||
key = DataRequest.GetDictionaryJsonObject<Guid>(requestData, "key");
|
key = DataRequest.GetDictionaryJsonObject<Guid>(requestData, "key");
|
||||||
if (Server.IsLoginKey(key))
|
|
||||||
|
GeneralEventArgs eventArgs = new();
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeLogoutEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeLogoutEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
msg = DataRequestService.GetPluginCancelString(DataRequestType.RunTime_Logout, eventArgs);
|
||||||
|
ServerHelper.WriteLine(msg, InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else if (Server.IsLoginKey(key))
|
||||||
{
|
{
|
||||||
// 从玩家列表移除
|
// 从玩家列表移除
|
||||||
Server.RemoveUser();
|
Server.RemoveUser();
|
||||||
Server.GetUsersCount();
|
Server.GetUsersCount();
|
||||||
msg = "你已成功退出登录! ";
|
msg = "你已成功退出登录! ";
|
||||||
}
|
}
|
||||||
|
else eventArgs.Success = false;
|
||||||
|
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeLogoutEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeLogoutEvent(this, eventArgs);
|
||||||
}
|
}
|
||||||
resultData.Add("msg", msg);
|
resultData.Add("msg", msg);
|
||||||
resultData.Add("key", key);
|
resultData.Add("key", key);
|
||||||
@ -258,6 +273,22 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
string gameModule = DataRequest.GetDictionaryJsonObject<string>(requestData, "moduleServer") ?? "";
|
string gameModule = DataRequest.GetDictionaryJsonObject<string>(requestData, "moduleServer") ?? "";
|
||||||
string gameMap = DataRequest.GetDictionaryJsonObject<string>(requestData, "map") ?? "";
|
string gameMap = DataRequest.GetDictionaryJsonObject<string>(requestData, "map") ?? "";
|
||||||
bool isRank = DataRequest.GetDictionaryJsonObject<bool>(requestData, "isRank");
|
bool isRank = DataRequest.GetDictionaryJsonObject<bool>(requestData, "isRank");
|
||||||
|
User user = DataRequest.GetDictionaryJsonObject<User>(requestData, "master") ?? Factory.GetUser();
|
||||||
|
string password = DataRequest.GetDictionaryJsonObject<string>(requestData, "password") ?? "";
|
||||||
|
int maxusers = DataRequest.GetDictionaryJsonObject<int>(requestData, "maxUsers");
|
||||||
|
|
||||||
|
RoomEventArgs eventArgs = new(type, password);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeCreateRoomEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeCreateRoomEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Main_CreateRoom, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
resultData.Add("room", room);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ServerHelper.WriteLine("[CreateRoom] " + RoomSet.GetTypeString(type) + " (" + string.Join(", ", [gameModule, gameMap]) + ")", InvokeMessageType.DataRequest);
|
ServerHelper.WriteLine("[CreateRoom] " + RoomSet.GetTypeString(type) + " (" + string.Join(", ", [gameModule, gameMap]) + ")", InvokeMessageType.DataRequest);
|
||||||
if (gameModule == "" || gameMap == "" || FunGameSystem.GameModuleLoader is null || !FunGameSystem.GameModuleLoader.ModuleServers.ContainsKey(gameModule) || !FunGameSystem.GameModuleLoader.Maps.ContainsKey(gameMap))
|
if (gameModule == "" || gameMap == "" || FunGameSystem.GameModuleLoader is null || !FunGameSystem.GameModuleLoader.ModuleServers.ContainsKey(gameModule) || !FunGameSystem.GameModuleLoader.Maps.ContainsKey(gameMap))
|
||||||
{
|
{
|
||||||
@ -265,9 +296,6 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
resultData.Add("room", room);
|
resultData.Add("room", room);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
User user = DataRequest.GetDictionaryJsonObject<User>(requestData, "master") ?? Factory.GetUser();
|
|
||||||
string password = DataRequest.GetDictionaryJsonObject<string>(requestData, "password") ?? "";
|
|
||||||
int maxusers = DataRequest.GetDictionaryJsonObject<int>(requestData, "maxUsers");
|
|
||||||
|
|
||||||
if (user.Id != 0)
|
if (user.Id != 0)
|
||||||
{
|
{
|
||||||
@ -297,6 +325,11 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = room.Roomid != "-1";
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterCreateRoomEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterCreateRoomEvent(this, eventArgs);
|
||||||
|
}
|
||||||
resultData.Add("room", room);
|
resultData.Add("room", room);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,9 +356,24 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
bool isMaster = DataRequest.GetDictionaryJsonObject<bool>(requestData, "isMaster");
|
bool isMaster = DataRequest.GetDictionaryJsonObject<bool>(requestData, "isMaster");
|
||||||
|
|
||||||
if (roomid != "-1" && FunGameSystem.RoomList.IsExist(roomid))
|
if (roomid != "-1" && FunGameSystem.RoomList.IsExist(roomid))
|
||||||
|
{
|
||||||
|
Room room = FunGameSystem.RoomList[roomid];
|
||||||
|
RoomEventArgs eventArgs = new(room);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeQuitRoomEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeQuitRoomEvent(this, eventArgs);
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Main_QuitRoom, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
result = await Server.QuitRoom(roomid, isMaster);
|
result = await Server.QuitRoom(roomid, isMaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = result;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterQuitRoomEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterQuitRoomEvent(this, eventArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resultData.Add("result", result);
|
resultData.Add("result", result);
|
||||||
}
|
}
|
||||||
@ -344,13 +392,22 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
|
|
||||||
if (roomid != "-1")
|
if (roomid != "-1")
|
||||||
{
|
{
|
||||||
if (SQLHelper != null)
|
Room room = FunGameSystem.RoomList[roomid];
|
||||||
|
RoomEventArgs eventArgs = new(room);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeIntoRoomEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeIntoRoomEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Main_IntoRoom, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else if (SQLHelper != null)
|
||||||
{
|
{
|
||||||
SQLHelper.ExecuteDataSet(RoomQuery.Select_IsExistRoom(SQLHelper, roomid));
|
SQLHelper.ExecuteDataSet(RoomQuery.Select_IsExistRoom(SQLHelper, roomid));
|
||||||
if (SQLHelper.Success)
|
if (SQLHelper.Success)
|
||||||
{
|
{
|
||||||
FunGameSystem.RoomList.IntoRoom(roomid, Server.User);
|
FunGameSystem.RoomList.IntoRoom(roomid, Server.User);
|
||||||
Server.InRoom = FunGameSystem.RoomList[roomid];
|
Server.InRoom = room;
|
||||||
Server.User.OnlineState = OnlineState.InRoom;
|
Server.User.OnlineState = OnlineState.InRoom;
|
||||||
await Server.SendClients(Server.Listener.ClientList.Where(c => c != null && roomid == c.InRoom.Roomid && c.User.Id != 0),
|
await Server.SendClients(Server.Listener.ClientList.Where(c => c != null && roomid == c.InRoom.Roomid && c.User.Id != 0),
|
||||||
SocketMessageType.Chat, Server.User.Username, DateTimeUtility.GetNowShortTime() + " [ " + Server.User.Username + " ] 进入了房间。");
|
SocketMessageType.Chat, Server.User.Username, DateTimeUtility.GetNowShortTime() + " [ " + Server.User.Username + " ] 进入了房间。");
|
||||||
@ -361,6 +418,10 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
FunGameSystem.RoomList.RemoveRoom(roomid);
|
FunGameSystem.RoomList.RemoveRoom(roomid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = result;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterIntoRoomEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterIntoRoomEvent(this, eventArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultData.Add("result", result);
|
resultData.Add("result", result);
|
||||||
@ -376,14 +437,29 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
bool result = true;
|
bool result = true;
|
||||||
if (requestData.Count >= 1)
|
if (requestData.Count >= 1)
|
||||||
{
|
{
|
||||||
bool iscancel = DataRequest.GetDictionaryJsonObject<bool>(requestData, "isCancel");
|
bool isCancel = DataRequest.GetDictionaryJsonObject<bool>(requestData, "isCancel");
|
||||||
if (!iscancel)
|
if (!isCancel)
|
||||||
|
{
|
||||||
|
GeneralEventArgs eventArgs = new();
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeStartMatchEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeStartMatchEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Main_MatchRoom, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ServerHelper.WriteLine("[MatchRoom] Start", InvokeMessageType.DataRequest);
|
ServerHelper.WriteLine("[MatchRoom] Start", InvokeMessageType.DataRequest);
|
||||||
RoomType type = DataRequest.GetDictionaryJsonObject<RoomType>(requestData, "roomType");
|
RoomType type = DataRequest.GetDictionaryJsonObject<RoomType>(requestData, "roomType");
|
||||||
User user = DataRequest.GetDictionaryJsonObject<User>(requestData, "matcher") ?? Factory.GetUser();
|
User user = DataRequest.GetDictionaryJsonObject<User>(requestData, "matcher") ?? Factory.GetUser();
|
||||||
StartMatching(type, user);
|
StartMatching(type, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = !eventArgs.Cancel;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterStartMatchEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterStartMatchEvent(this, eventArgs);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 取消匹配
|
// 取消匹配
|
||||||
@ -453,11 +529,24 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
if (requestData.Count >= 1)
|
if (requestData.Count >= 1)
|
||||||
{
|
{
|
||||||
string msg = DataRequest.GetDictionaryJsonObject<string>(requestData, "msg") ?? "";
|
string msg = DataRequest.GetDictionaryJsonObject<string>(requestData, "msg") ?? "";
|
||||||
if (msg.Trim() != "")
|
|
||||||
|
SendTalkEventArgs eventArgs = new(msg);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeSendTalkEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeSendTalkEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Main_Chat, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else if (msg.Trim() != "")
|
||||||
{
|
{
|
||||||
await Server.SendClients(Server.Listener.ClientList.Where(c => c != null && Server.InRoom.Roomid == c.InRoom.Roomid && c.User.Id != 0),
|
await Server.SendClients(Server.Listener.ClientList.Where(c => c != null && Server.InRoom.Roomid == c.InRoom.Roomid && c.User.Id != 0),
|
||||||
SocketMessageType.Chat, Server.User.Username, msg);
|
SocketMessageType.Chat, Server.User.Username, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = !eventArgs.Cancel;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterSendTalkEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterSendTalkEvent(this, eventArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,6 +564,16 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
bool isMaster = DataRequest.GetDictionaryJsonObject<bool>(requestData, "isMaster");
|
bool isMaster = DataRequest.GetDictionaryJsonObject<bool>(requestData, "isMaster");
|
||||||
|
|
||||||
if (roomid != "-1")
|
if (roomid != "-1")
|
||||||
|
{
|
||||||
|
GeneralEventArgs eventArgs = new(FunGameSystem.RoomList[roomid], isMaster);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeStartGameEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeStartGameEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Main_StartGame, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (isMaster)
|
if (isMaster)
|
||||||
{
|
{
|
||||||
@ -529,6 +628,11 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
Server.SendSystemMessage(ShowMessageType.None, "15秒内只能发送一次提醒,请稍后再试。", "", 0, Server.User.Username);
|
Server.SendSystemMessage(ShowMessageType.None, "15秒内只能发送一次提醒,请稍后再试。", "", 0, Server.User.Username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = result;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterStartGameEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterStartGameEvent(this, eventArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resultData.Add("result", result);
|
resultData.Add("result", result);
|
||||||
}
|
}
|
||||||
@ -786,31 +890,42 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
string msg = "";
|
string msg = "";
|
||||||
string room = DataRequest.GetDictionaryJsonObject<string>(requestData, "roomid") ?? "-1";
|
string roomid = DataRequest.GetDictionaryJsonObject<string>(requestData, "roomid") ?? "-1";
|
||||||
RoomType newType = DataRequest.GetDictionaryJsonObject<RoomType>(requestData, "type");
|
RoomType newType = DataRequest.GetDictionaryJsonObject<RoomType>(requestData, "type");
|
||||||
string newPassword = DataRequest.GetDictionaryJsonObject<string>(requestData, "password") ?? "";
|
string newPassword = DataRequest.GetDictionaryJsonObject<string>(requestData, "password") ?? "";
|
||||||
int newMaxUsers = DataRequest.GetDictionaryJsonObject<int>(requestData, "maxUsers");
|
int newMaxUsers = DataRequest.GetDictionaryJsonObject<int>(requestData, "maxUsers");
|
||||||
string newModule = DataRequest.GetDictionaryJsonObject<string>(requestData, "module") ?? "";
|
string newModule = DataRequest.GetDictionaryJsonObject<string>(requestData, "module") ?? "";
|
||||||
string newMap = DataRequest.GetDictionaryJsonObject<string>(requestData, "map") ?? "";
|
string newMap = DataRequest.GetDictionaryJsonObject<string>(requestData, "map") ?? "";
|
||||||
User user = Server.User;
|
User user = Server.User;
|
||||||
if (room != "-1" && FunGameSystem.RoomList.IsExist(room))
|
if (roomid != "-1" && FunGameSystem.RoomList.IsExist(roomid))
|
||||||
{
|
{
|
||||||
Room r = FunGameSystem.RoomList[room];
|
Room room = FunGameSystem.RoomList[roomid];
|
||||||
if (user.Id != r.RoomMaster.Id)
|
RoomEventArgs eventArgs = new(room);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeChangeRoomSettingEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeChangeRoomSettingEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
msg = DataRequestService.GetPluginCancelString(DataRequestType.Room_UpdateRoomSettings, eventArgs);
|
||||||
|
ServerHelper.WriteLine(msg, InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (user.Id != room.RoomMaster.Id)
|
||||||
{
|
{
|
||||||
msg = "更新失败,只有房主才可以更新房间设置。";
|
msg = "更新失败,只有房主才可以更新房间设置。";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
ServerHelper.WriteLine("[UpdateRoomSettings] User: " + user.Username + " RoomID: " + r.Roomid);
|
ServerHelper.WriteLine("[UpdateRoomSettings] User: " + user.Username + " RoomID: " + room.Roomid);
|
||||||
if (r.RoomState == RoomState.Created)
|
if (room.RoomState == RoomState.Created)
|
||||||
{
|
{
|
||||||
r.RoomType = newType;
|
room.RoomType = newType;
|
||||||
r.Password = newPassword;
|
room.Password = newPassword;
|
||||||
r.MaxUsers = newMaxUsers;
|
room.MaxUsers = newMaxUsers;
|
||||||
r.GameModule = newModule;
|
room.GameModule = newModule;
|
||||||
r.GameMap = newMap;
|
room.GameMap = newMap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -818,9 +933,14 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = result;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterChangeRoomSettingEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterChangeRoomSettingEvent(this, eventArgs);
|
||||||
|
}
|
||||||
resultData.Add("result", result);
|
resultData.Add("result", result);
|
||||||
resultData.Add("msg", msg);
|
resultData.Add("msg", msg);
|
||||||
resultData.Add("room", room);
|
resultData.Add("room", roomid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -856,6 +976,16 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
if (roomid != "-1" && FunGameSystem.RoomList.IsExist(roomid) && newMaster.Id != 0)
|
if (roomid != "-1" && FunGameSystem.RoomList.IsExist(roomid) && newMaster.Id != 0)
|
||||||
{
|
{
|
||||||
Room room = FunGameSystem.RoomList[roomid];
|
Room room = FunGameSystem.RoomList[roomid];
|
||||||
|
RoomEventArgs eventArgs = new(room);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeChangeRoomSettingEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeChangeRoomSettingEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Room_UpdateRoomSettings, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
User oldMaster = room.RoomMaster;
|
User oldMaster = room.RoomMaster;
|
||||||
room.RoomMaster = newMaster;
|
room.RoomMaster = newMaster;
|
||||||
result = true;
|
result = true;
|
||||||
@ -870,6 +1000,11 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = result;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterChangeRoomSettingEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterChangeRoomSettingEvent(this, eventArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1021,12 +1156,29 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
if (SQLHelper != null && requestData.Count > 0)
|
if (SQLHelper != null && requestData.Count > 0)
|
||||||
{
|
{
|
||||||
User user = DataRequest.GetDictionaryJsonObject<User>(requestData, "user") ?? Factory.GetUser();
|
User user = DataRequest.GetDictionaryJsonObject<User>(requestData, "user") ?? Factory.GetUser();
|
||||||
|
|
||||||
|
GeneralEventArgs eventArgs = new(user);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeChangeProfileEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeChangeProfileEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
msg = DataRequestService.GetPluginCancelString(DataRequestType.UserCenter_UpdateUser, eventArgs);
|
||||||
|
ServerHelper.WriteLine(msg, InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
SQLHelper.UpdateUser(user);
|
SQLHelper.UpdateUser(user);
|
||||||
if (SQLHelper.Success)
|
if (SQLHelper.Success)
|
||||||
{
|
{
|
||||||
msg = "";
|
msg = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = msg == "";
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterChangeProfileEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterChangeProfileEvent(this, eventArgs);
|
||||||
|
}
|
||||||
resultData.Add("msg", msg);
|
resultData.Add("msg", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1042,7 +1194,17 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
{
|
{
|
||||||
string username = DataRequest.GetDictionaryJsonObject<string>(requestData, "username") ?? "";
|
string username = DataRequest.GetDictionaryJsonObject<string>(requestData, "username") ?? "";
|
||||||
string password = DataRequest.GetDictionaryJsonObject<string>(requestData, "password") ?? "";
|
string password = DataRequest.GetDictionaryJsonObject<string>(requestData, "password") ?? "";
|
||||||
if (username.Trim() != "" && password.Trim() != "")
|
|
||||||
|
GeneralEventArgs eventArgs = new(username, password);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeChangeAccountSettingEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeChangeAccountSettingEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
msg = DataRequestService.GetPluginCancelString(_lastRequest, eventArgs);
|
||||||
|
ServerHelper.WriteLine(msg, InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else if (username.Trim() != "" && password.Trim() != "")
|
||||||
{
|
{
|
||||||
FunGameSystem.UpdateUserKey(username);
|
FunGameSystem.UpdateUserKey(username);
|
||||||
password = password.Encrypt(FunGameSystem.GetUserKey(username));
|
password = password.Encrypt(FunGameSystem.GetUserKey(username));
|
||||||
@ -1053,6 +1215,10 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
msg = "";
|
msg = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = msg == "";
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterChangeAccountSettingEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterChangeAccountSettingEvent(this, eventArgs);
|
||||||
}
|
}
|
||||||
resultData.Add("msg", msg);
|
resultData.Add("msg", msg);
|
||||||
}
|
}
|
||||||
@ -1063,7 +1229,15 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
/// <param name="resultData"></param>
|
/// <param name="resultData"></param>
|
||||||
private void DailySignIn(Dictionary<string, object> resultData)
|
private void DailySignIn(Dictionary<string, object> resultData)
|
||||||
{
|
{
|
||||||
if (SQLHelper != null)
|
GeneralEventArgs eventArgs = new();
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeSignInEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeSignInEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.UserCenter_DailySignIn, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else if (SQLHelper != null)
|
||||||
{
|
{
|
||||||
long userId = Server.User.Id;
|
long userId = Server.User.Id;
|
||||||
if (userId != 0)
|
if (userId != 0)
|
||||||
@ -1088,12 +1262,21 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
SQLHelper.Execute(UserSignIns.Update_UserSignIn(SQLHelper, userId, days));
|
SQLHelper.Execute(UserSignIns.Update_UserSignIn(SQLHelper, userId, days));
|
||||||
if (SQLHelper.Success)
|
if (SQLHelper.Success)
|
||||||
{
|
{
|
||||||
|
eventArgs.Success = true;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterSignInEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterSignInEvent(this, eventArgs);
|
||||||
|
|
||||||
resultData.Add("msg", $"签到成功!你已经连续签到 {days} 天!");
|
resultData.Add("msg", $"签到成功!你已经连续签到 {days} 天!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = false;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterSignInEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterSignInEvent(this, eventArgs);
|
||||||
|
|
||||||
resultData.Add("msg", "签到失败!");
|
resultData.Add("msg", "签到失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1113,7 +1296,20 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
if (requestData.Count > 0)
|
if (requestData.Count > 0)
|
||||||
{
|
{
|
||||||
long[] ids = DataRequest.GetDictionaryJsonObject<long[]>(requestData, "ids") ?? [];
|
long[] ids = DataRequest.GetDictionaryJsonObject<long[]>(requestData, "ids") ?? [];
|
||||||
stores = SQLHelper?.GetStoresWithGoods(ids) ?? [];
|
|
||||||
|
GeneralEventArgs eventArgs = new(ids);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeOpenStoreEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeOpenStoreEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Inventory_GetStore, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else stores = SQLHelper?.GetStoresWithGoods(ids) ?? [];
|
||||||
|
|
||||||
|
eventArgs.Success = stores.Count > 0;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterOpenStoreEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterOpenStoreEvent(this, eventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
resultData.Add("result", stores.Count > 0);
|
resultData.Add("result", stores.Count > 0);
|
||||||
@ -1175,6 +1371,16 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
Dictionary<long, int> counts = DataRequest.GetDictionaryJsonObject<Dictionary<long, int>>(requestData, "counts") ?? [];
|
Dictionary<long, int> counts = DataRequest.GetDictionaryJsonObject<Dictionary<long, int>>(requestData, "counts") ?? [];
|
||||||
bool ignore = DataRequest.GetDictionaryJsonObject<bool>(requestData, "ignore");
|
bool ignore = DataRequest.GetDictionaryJsonObject<bool>(requestData, "ignore");
|
||||||
|
|
||||||
|
GeneralEventArgs eventArgs = new(DataRequestType.Inventory_StoreBuy, storeid, userid, currency, counts, ignore);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeBuyItemEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeBuyItemEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Inventory_StoreBuy, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Store? store = SQLHelper.GetStore(storeid);
|
Store? store = SQLHelper.GetStore(storeid);
|
||||||
User? user = SQLHelper.GetUserById(userid, true);
|
User? user = SQLHelper.GetUserById(userid, true);
|
||||||
if (store != null && user != null)
|
if (store != null && user != null)
|
||||||
@ -1253,6 +1459,11 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = result;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterBuyItemEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterBuyItemEvent(this, eventArgs);
|
||||||
|
}
|
||||||
resultData.Add("result", result);
|
resultData.Add("result", result);
|
||||||
resultData.Add("msg", string.Join("\r\n", buyResult));
|
resultData.Add("msg", string.Join("\r\n", buyResult));
|
||||||
}
|
}
|
||||||
@ -1294,13 +1505,22 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
if (SQLHelper != null && requestData.Count > 0)
|
if (SQLHelper != null && requestData.Count > 0)
|
||||||
{
|
{
|
||||||
Guid itemGuid = DataRequest.GetDictionaryJsonObject<Guid>(requestData, "itemGuid");
|
Guid itemGuid = DataRequest.GetDictionaryJsonObject<Guid>(requestData, "itemGuid");
|
||||||
|
|
||||||
MarketItem? marketItem = SQLHelper.GetMarketItem(itemGuid);
|
|
||||||
if (marketItem != null)
|
|
||||||
{
|
|
||||||
long userid = DataRequest.GetDictionaryJsonObject<long>(requestData, "userid");
|
long userid = DataRequest.GetDictionaryJsonObject<long>(requestData, "userid");
|
||||||
double price = DataRequest.GetDictionaryJsonObject<double>(requestData, "price");
|
double price = DataRequest.GetDictionaryJsonObject<double>(requestData, "price");
|
||||||
|
|
||||||
|
GeneralEventArgs eventArgs = new(DataRequestType.Inventory_MarketBuy, itemGuid, userid, price);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeBuyItemEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeBuyItemEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Inventory_MarketBuy, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MarketItem? marketItem = SQLHelper.GetMarketItem(itemGuid);
|
||||||
|
if (marketItem != null)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
User? buyer = SQLHelper.GetUserById(userid, true);
|
User? buyer = SQLHelper.GetUserById(userid, true);
|
||||||
@ -1367,6 +1587,11 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
msg = "目标物品不存在。";
|
msg = "目标物品不存在。";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = result;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterBuyItemEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterBuyItemEvent(this, eventArgs);
|
||||||
|
}
|
||||||
resultData.Add("result", result);
|
resultData.Add("result", result);
|
||||||
resultData.Add("msg", msg);
|
resultData.Add("msg", msg);
|
||||||
}
|
}
|
||||||
@ -1407,6 +1632,17 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
long userid = DataRequest.GetDictionaryJsonObject<long>(requestData, "userid");
|
long userid = DataRequest.GetDictionaryJsonObject<long>(requestData, "userid");
|
||||||
Character[] targets = DataRequest.GetDictionaryJsonObject<Character[]>(requestData, "targets") ?? [];
|
Character[] targets = DataRequest.GetDictionaryJsonObject<Character[]>(requestData, "targets") ?? [];
|
||||||
long useCount = DataRequest.GetDictionaryJsonObject<long>(requestData, "useCount");
|
long useCount = DataRequest.GetDictionaryJsonObject<long>(requestData, "useCount");
|
||||||
|
|
||||||
|
GeneralEventArgs eventArgs = new(itemGuid, userid, targets, useCount);
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeUseItemEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeUseItemEvent(this, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine(DataRequestService.GetPluginCancelString(DataRequestType.Inventory_Use, eventArgs), InvokeMessageType.DataRequest, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
User? user = SQLHelper.GetUserById(userid, true);
|
User? user = SQLHelper.GetUserById(userid, true);
|
||||||
if (user != null && user.Inventory.Items.FirstOrDefault(i => i.Guid == itemGuid) is Item item)
|
if (user != null && user.Inventory.Items.FirstOrDefault(i => i.Guid == itemGuid) is Item item)
|
||||||
{
|
{
|
||||||
@ -1427,6 +1663,11 @@ namespace Milimoe.FunGame.Server.Controller
|
|||||||
msg = "";
|
msg = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = result;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterUseItemEvent(this, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterUseItemEvent(this, eventArgs);
|
||||||
|
}
|
||||||
resultData.Add("result", result);
|
resultData.Add("result", result);
|
||||||
resultData.Add("msg", msg);
|
resultData.Add("msg", msg);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,48 @@ bool Running = true;
|
|||||||
SocketListener? SocketListener = null;
|
SocketListener? SocketListener = null;
|
||||||
HTTPListener? WebSocketListener = null;
|
HTTPListener? WebSocketListener = null;
|
||||||
|
|
||||||
StartServer();
|
ServerHelper.WriteLine("正在读取配置文件并初始化服务 . . .");
|
||||||
|
|
||||||
|
// 检查是否存在配置文件
|
||||||
|
if (!INIHelper.ExistINIFile())
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine("未检测到配置文件,将自动创建配置文件 . . .");
|
||||||
|
INIHelper.Init(Config.FunGameType);
|
||||||
|
ServerHelper.WriteLine("配置文件FunGame.ini创建成功,请修改该配置文件,然后重启服务器。");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ServerHelper.GetServerSettings();
|
||||||
|
Console.Title = Config.ServerName + " - FunGame Server Port: " + Config.ServerPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化命令菜单
|
||||||
|
ServerHelper.InitOrderList();
|
||||||
|
|
||||||
|
// 初始化SQLHelper
|
||||||
|
FunGameSystem.InitSQLHelper();
|
||||||
|
|
||||||
|
// 初始化MailSender
|
||||||
|
FunGameSystem.InitMailSender();
|
||||||
|
|
||||||
|
// 读取Server插件
|
||||||
|
FunGameSystem.GetServerPlugins();
|
||||||
|
|
||||||
|
// 读取游戏模组
|
||||||
|
if (!FunGameSystem.GetGameModuleList())
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine("服务器似乎未安装任何游戏模组,请检查是否正确安装它们。");
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerHelper.WriteLine("请输入 help 来获取帮助,按下 Ctrl+C 关闭服务器。");
|
||||||
|
|
||||||
|
// 初始化服务器其他配置文件
|
||||||
|
FunGameSystem.InitOtherConfig();
|
||||||
|
|
||||||
|
ServerHelper.PrintFunGameTitle();
|
||||||
|
|
||||||
|
StartServerListening();
|
||||||
|
|
||||||
Console.CancelKeyPress += (sender, e) =>
|
Console.CancelKeyPress += (sender, e) =>
|
||||||
{
|
{
|
||||||
@ -65,7 +106,7 @@ while (Running)
|
|||||||
case OrderDictionary.Restart:
|
case OrderDictionary.Restart:
|
||||||
if (SocketListener is null || WebSocketListener is null)
|
if (SocketListener is null || WebSocketListener is null)
|
||||||
{
|
{
|
||||||
StartServer();
|
StartServerListening();
|
||||||
}
|
}
|
||||||
else ServerHelper.WriteLine("服务器正在运行,请手动结束服务器进程再启动!");
|
else ServerHelper.WriteLine("服务器正在运行,请手动结束服务器进程再启动!");
|
||||||
break;
|
break;
|
||||||
@ -83,53 +124,12 @@ while (Running)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartServer()
|
void StartServerListening()
|
||||||
{
|
{
|
||||||
TaskUtility.NewTask(async () =>
|
TaskUtility.NewTask(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerHelper.WriteLine("正在读取配置文件并初始化服务 . . .");
|
|
||||||
|
|
||||||
// 检查是否存在配置文件
|
|
||||||
if (!INIHelper.ExistINIFile())
|
|
||||||
{
|
|
||||||
ServerHelper.WriteLine("未检测到配置文件,将自动创建配置文件 . . .");
|
|
||||||
INIHelper.Init(Config.FunGameType);
|
|
||||||
ServerHelper.WriteLine("配置文件FunGame.ini创建成功,请修改该配置文件,然后重启服务器。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ServerHelper.GetServerSettings();
|
|
||||||
Console.Title = Config.ServerName + " - FunGame Server Port: " + Config.ServerPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 初始化命令菜单
|
|
||||||
ServerHelper.InitOrderList();
|
|
||||||
|
|
||||||
// 初始化SQLHelper
|
|
||||||
FunGameSystem.InitSQLHelper();
|
|
||||||
|
|
||||||
// 初始化MailSender
|
|
||||||
FunGameSystem.InitMailSender();
|
|
||||||
|
|
||||||
// 读取Server插件
|
|
||||||
FunGameSystem.GetServerPlugins();
|
|
||||||
|
|
||||||
// 读取游戏模组
|
|
||||||
if (!FunGameSystem.GetGameModuleList())
|
|
||||||
{
|
|
||||||
ServerHelper.WriteLine("服务器似乎未安装任何游戏模组,请检查是否正确安装它们。");
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerHelper.WriteLine("请输入 help 来获取帮助,按下 Ctrl+C 关闭服务器。");
|
|
||||||
|
|
||||||
// 初始化服务器其他配置文件
|
|
||||||
FunGameSystem.InitOtherConfig();
|
|
||||||
|
|
||||||
ServerHelper.PrintFunGameTitle();
|
|
||||||
|
|
||||||
// 使用Socket还是WebSocket
|
// 使用Socket还是WebSocket
|
||||||
bool useWebSocket = Config.UseWebSocket;
|
bool useWebSocket = Config.UseWebSocket;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ using Milimoe.FunGame.Core.Api.Utility;
|
|||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
using Milimoe.FunGame.Core.Interface.Base;
|
using Milimoe.FunGame.Core.Interface.Base;
|
||||||
using Milimoe.FunGame.Core.Library.Common.Addon;
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
using Milimoe.FunGame.Core.Library.Common.Network;
|
using Milimoe.FunGame.Core.Library.Common.Network;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.SQLScript.Common;
|
using Milimoe.FunGame.Core.Library.SQLScript.Common;
|
||||||
@ -77,6 +78,16 @@ namespace Milimoe.FunGame.Server.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type == SocketMessageType.EndGame)
|
if (type == SocketMessageType.EndGame)
|
||||||
|
{
|
||||||
|
GeneralEventArgs eventArgs = new();
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnBeforeEndGameEvent(DataRequestController, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnBeforeEndGameEvent(DataRequestController, eventArgs);
|
||||||
|
|
||||||
|
if (eventArgs.Cancel)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine($"{SocketSet.GetTypeString(SocketMessageType.EndGame)} 请求已取消。", InvokeMessageType.Core, LogLevel.Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (NowGamingServer != null && NowGamingServer.IsAnonymous)
|
if (NowGamingServer != null && NowGamingServer.IsAnonymous)
|
||||||
{
|
{
|
||||||
@ -85,7 +96,13 @@ namespace Milimoe.FunGame.Server.Model
|
|||||||
NowGamingServer = null;
|
NowGamingServer = null;
|
||||||
User.OnlineState = OnlineState.InRoom;
|
User.OnlineState = OnlineState.InRoom;
|
||||||
if (User.Id == InRoom.RoomMaster.Id) InRoom.RoomState = RoomState.Created;
|
if (User.Id == InRoom.RoomMaster.Id) InRoom.RoomState = RoomState.Created;
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
eventArgs.Success = !eventArgs.Cancel;
|
||||||
|
FunGameSystem.ServerPluginLoader?.OnAfterEndGameEvent(DataRequestController, eventArgs);
|
||||||
|
FunGameSystem.WebAPIPluginLoader?.OnAfterEndGameEvent(DataRequestController, eventArgs);
|
||||||
|
|
||||||
|
return !eventArgs.Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == SocketMessageType.AnonymousGameServer)
|
if (type == SocketMessageType.AnonymousGameServer)
|
||||||
|
@ -18,7 +18,7 @@ namespace Milimoe.FunGame.Server.Services
|
|||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static string GetPluginCancelString(DataRequestType type, GeneralEventArgs e) => $"{DataRequestSet.GetTypeString(type)} 请求已取消。{(e.EventMsg != "" ? $"原因:{e.EventMsg}" : "")}";
|
public static string GetPluginCancelString(DataRequestType type, GeneralEventArgs e) => $"{DataRequestSet.GetTypeString(type)} 请求已取消。{(e.EventMsg != "" ? $"原因:{e.EventMsg}" : "")}";
|
||||||
|
|
||||||
#region Register
|
#region Register
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user