mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 16:16:33 +00:00
修改部分常量和添加Room相关的SQLScript (#7)
This commit is contained in:
parent
84cbedf1f6
commit
2a574bf8d6
@ -34,7 +34,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
|||||||
|
|
||||||
public static ServerSocket StartListening(int Port = 22222, int MaxConnection = 0)
|
public static ServerSocket StartListening(int Port = 22222, int MaxConnection = 0)
|
||||||
{
|
{
|
||||||
if (MaxConnection <= 0) MaxConnection = SocketSet.MaxConnection_General;
|
if (MaxConnection <= 0) MaxConnection = SocketSet.MaxConnection_2C2G;
|
||||||
System.Net.Sockets.Socket? socket = SocketManager.StartListening(Port, MaxConnection);
|
System.Net.Sockets.Socket? socket = SocketManager.StartListening(Port, MaxConnection);
|
||||||
if (socket != null) return new ServerSocket(socket, Port);
|
if (socket != null) return new ServerSocket(socket, Port);
|
||||||
else throw new SocketCreateListenException();
|
else throw new SocketCreateListenException();
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
{
|
{
|
||||||
public const int MaxRetryTimes = 20;
|
public const int MaxRetryTimes = 20;
|
||||||
public const int MaxConnection_1C2G = 10;
|
public const int MaxConnection_1C2G = 10;
|
||||||
public const int MaxConnection_General = 20;
|
public const int MaxConnection_2C2G = 20;
|
||||||
public const int MaxConnection_4C4G = 40;
|
public const int MaxConnection_4C4G = 40;
|
||||||
|
|
||||||
public const string Socket = "Socket";
|
public const string Socket = "Socket";
|
||||||
@ -59,4 +59,12 @@
|
|||||||
public const string RoomSetting = "RoomSetting";
|
public const string RoomSetting = "RoomSetting";
|
||||||
public const string UserCenter = "UserCenter";
|
public const string UserCenter = "UserCenter";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class GameMode
|
||||||
|
{
|
||||||
|
public const string GameMode_Mix = "混战模式";
|
||||||
|
public const string GameMode_Team = "团队模式";
|
||||||
|
public const string GameMode_MixHasPass = "带密码的混战模式";
|
||||||
|
public const string GameMode_TeamHasPass = "带密码的团队模式";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,12 +8,6 @@
|
|||||||
Cancel
|
Cancel
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CreateRoomState
|
|
||||||
{
|
|
||||||
Creating,
|
|
||||||
Success
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum RoomState
|
public enum RoomState
|
||||||
{
|
{
|
||||||
Created,
|
Created,
|
||||||
|
|||||||
@ -14,5 +14,33 @@
|
|||||||
public const string Column_Password = "Password";
|
public const string Column_Password = "Password";
|
||||||
public const string Select_Rooms = $"{Constant.Command_Select} {TableName}.{Constant.Command_All}, {UserQuery.TableName}.{UserQuery.Column_Username} {Constant.Command_As} {Column_RoomMasterName} " +
|
public const string Select_Rooms = $"{Constant.Command_Select} {TableName}.{Constant.Command_All}, {UserQuery.TableName}.{UserQuery.Column_Username} {Constant.Command_As} {Column_RoomMasterName} " +
|
||||||
$"{Constant.Command_From} {TableName} {Constant.Command_LeftJoin} {UserQuery.TableName} {Constant.Command_On} {UserQuery.TableName}.{UserQuery.Column_UID} = {TableName}.{Column_RoomMaster}";
|
$"{Constant.Command_From} {TableName} {Constant.Command_LeftJoin} {UserQuery.TableName} {Constant.Command_On} {UserQuery.TableName}.{UserQuery.Column_UID} = {TableName}.{Column_RoomMaster}";
|
||||||
|
|
||||||
|
public static string Insert_CreateRoom(string RoomID, long RoomMaster, Library.Constant.RoomType RoomType, string Password)
|
||||||
|
{
|
||||||
|
Library.Constant.RoomState RoomState = Library.Constant.RoomState.Created;
|
||||||
|
DateTime NowTime = DateTime.Now;
|
||||||
|
bool HasPass = false;
|
||||||
|
if (Password.Trim() != "")
|
||||||
|
{
|
||||||
|
HasPass = true;
|
||||||
|
}
|
||||||
|
return $"{Constant.Command_Insert} {Constant.Command_Into} {TableName} ({Column_RoomID}, {Column_CreateTime}, {Column_RoomMaster}, {Column_RoomType}, {Column_RoomState}, {Column_HasPass}, {Column_Password})" +
|
||||||
|
$" {Constant.Command_Values} ('{RoomID}', '{NowTime}', {RoomMaster}, {(int)RoomType}, {(int)RoomState}, {(HasPass ? 1 : 0)}, '{Password}')";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Delete_QuitRoom(string RoomID, long RoomMaster)
|
||||||
|
{
|
||||||
|
return $"{Constant.Command_Delete} {Constant.Command_From} {TableName} {Constant.Command_Where} {Column_RoomID} = '{RoomID}' {Constant.Command_And} {Column_RoomMaster} = {RoomMaster}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Update_QuitRoom(string RoomID, long OldRoomMaster, long NewRoomMaster)
|
||||||
|
{
|
||||||
|
return $"{Constant.Command_Update} {TableName} {Constant.Command_Set} {Column_RoomMaster} = {NewRoomMaster} {Constant.Command_Where} {Column_RoomID} = '{RoomID}' {Constant.Command_And} {Column_RoomMaster} = {OldRoomMaster}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Select_IsExistRoom(string RoomID)
|
||||||
|
{
|
||||||
|
return $"{Constant.Command_Select} {Constant.Command_All} {Constant.Command_From} {TableName} {Constant.Command_Where} {Column_RoomID} = '{RoomID}'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,12 +25,12 @@
|
|||||||
return $"{Select_Users} {Constant.Command_Where} {Column_Username} = '{Username}' and {Column_Password} = '{Password}'";
|
return $"{Select_Users} {Constant.Command_Where} {Column_Username} = '{Username}' and {Column_Password} = '{Password}'";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Select_DuplicateEmail(string Email)
|
public static string Select_IsExistEmail(string Email)
|
||||||
{
|
{
|
||||||
return $"{Select_Users} {Constant.Command_Where} {Column_Email} = '{Email}'";
|
return $"{Select_Users} {Constant.Command_Where} {Column_Email} = '{Email}'";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Select_DuplicateUsername(string Username)
|
public static string Select_IsExistUsername(string Username)
|
||||||
{
|
{
|
||||||
return $"{Select_Users} {Constant.Command_Where} {Column_Username} = '{Username}'";
|
return $"{Select_Users} {Constant.Command_Where} {Column_Username} = '{Username}'";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace Milimoe.FunGame.Core.Service
|
|||||||
/// <returns>服务器端专用Socket</returns>
|
/// <returns>服务器端专用Socket</returns>
|
||||||
internal static Socket? StartListening(int Port = 22222, int MaxConnection = 0)
|
internal static Socket? StartListening(int Port = 22222, int MaxConnection = 0)
|
||||||
{
|
{
|
||||||
if (MaxConnection <= 0) MaxConnection = SocketSet.MaxConnection_General;
|
if (MaxConnection <= 0) MaxConnection = SocketSet.MaxConnection_2C2G;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_ServerSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
_ServerSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user