完善房间

This commit is contained in:
sin365 2024-11-08 09:41:09 +08:00
parent 189e963f8f
commit 1184baf3a0
6 changed files with 60 additions and 11 deletions

View File

@ -101,6 +101,13 @@ namespace AxibugEmuOnline.Client.ClientCore
yield break;
int platform = 0;
bool bTest = true;
if (bTest)
{
yield return null;
Connect("192.168.0.47", 10492);
yield break;
}
UnityWebRequest request = UnityWebRequest.Get($"{App.httpAPI.WebSiteApi}/CheckStandInfo?platform={platform}&version={Application.version}");
yield return request.SendWebRequest();

View File

@ -7,6 +7,7 @@
OnRoomListAllUpdate,//房间列表全量刷新
OnRoomListSingleAdd,//房间列表中新增房间
OnRoomListSingleUpdate,//房间列表中单个更新
OnRoomListSingleClose,//房间关闭
OnRoomGetRoomScreen,//获取到房间数据

View File

@ -55,9 +55,11 @@ namespace AxibugEmuOnline.Client.Manager
}
#region
void AddOrUpdateRoomList(Protobuf_Room_MiniInfo roomInfo)
bool AddOrUpdateRoomList(Protobuf_Room_MiniInfo roomInfo)
{
bool bNew = !dictRoomListID2Info.ContainsKey(roomInfo.RoomID);
dictRoomListID2Info[roomInfo.RoomID] = roomInfo;
return bNew;
}
bool RemoveRoomList(int roomId)
{
@ -203,8 +205,14 @@ namespace AxibugEmuOnline.Client.Manager
Protobuf_Room_Update_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Update_RESP>(reqData);
if (msg.UpdateType == 0)
{
AddOrUpdateRoomList(msg.RoomMiniInfo);
Eventer.Instance.PostEvent(EEvent.OnRoomListSingleUpdate, msg.RoomMiniInfo.RoomID);
if (AddOrUpdateRoomList(msg.RoomMiniInfo))
{
Eventer.Instance.PostEvent(EEvent.OnRoomListSingleAdd, msg.RoomMiniInfo.RoomID);
}
else
{
Eventer.Instance.PostEvent(EEvent.OnRoomListSingleUpdate, msg.RoomMiniInfo.RoomID);
}
}
else
{

View File

@ -90,7 +90,7 @@ namespace AxibugEmuOnline.Client
public void OnCmdPing(byte[] reqData)
{
App.log.Debug($"OnCmdPing");
//App.log.Debug($"OnCmdPing");
Protobuf_Ping msg = ProtoBufHelper.DeSerizlize<Protobuf_Ping>(reqData);
Protobuf_Pong resp = new Protobuf_Pong()
{
@ -101,7 +101,7 @@ namespace AxibugEmuOnline.Client
public void OnCmdPong(byte[] reqData)
{
App.log.Debug($"OnCmdPong");
//App.log.Debug($"OnCmdPong");
Protobuf_Pong msg = ProtoBufHelper.DeSerizlize<Protobuf_Pong>(reqData);
if (LastPingSeed == msg.Seed)

View File

@ -221,6 +221,8 @@ namespace AxibugEmuOnline.Server.Manager
Console.WriteLine("标记玩家UID" + cinfo.UID + "为离线");
cinfo.IsOffline = true;
cinfo.LogOutDT = DateTime.Now;
AppSrv.g_Room.LeaveRoom(cinfo, cinfo.RoomState.RoomID);
}
public void RemoveClientForSocket(Socket sk)

View File

@ -131,7 +131,7 @@ namespace AxibugEmuOnline.Server
List<Data_RoomData> temp = GetRoomList();
foreach (var room in temp)
resp.RoomMiniInfoList.Add(GetProtoDataRoom(room));
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdChatmsg, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomList, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
}
public void CmdRoomGetScreen(Socket sk, byte[] reqData)
{
@ -196,6 +196,8 @@ namespace AxibugEmuOnline.Server
if (joinErrcode == ErrorCode.ErrorOk && bHadRoomStateChange)
SendRoomStateChange(newRoom);
SendRoomUpdateToAll(newRoom.RoomID, 0);
}
public void OnCmdRoomJoin(Socket sk, byte[] reqData)
@ -233,6 +235,33 @@ namespace AxibugEmuOnline.Server
AppSrv.g_Log.Debug($"OnCmdRoomLeave ");
ClientInfo _c = AppSrv.g_ClientMgr.GetClientForSocket(sk);
Protobuf_Room_Leave msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Leave>(reqData);
LeaveRoom(_c, msg.RoomID);
//Protobuf_Room_Leave_RESP resp = new Protobuf_Room_Leave_RESP();
//ErrorCode errcode;
//Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
//bool bHadRoomStateChange = false;
//if (room == null)
// errcode = ErrorCode.ErrorRoomNotFound;
//else
//{
// if (room.Leave(_c, out errcode, out bHadRoomStateChange))
// {
// resp.RoomID = msg.RoomID;
// }
//}
//AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomLeave, (int)errcode, ProtoBufHelper.Serizlize(resp));
//Protobuf_Room_MyRoom_State_Change(msg.RoomID);
//if (errcode == ErrorCode.ErrorOk && bHadRoomStateChange)
// SendRoomStateChange(room);
//SendRoomUpdateToAll(room.RoomID, 1);
//if (room.GetPlayerCount() < 1)
// RemoveRoom(room.RoomID);
}
public void LeaveRoom(ClientInfo _c,int RoomID)
{
Protobuf_Room_Leave_RESP resp = new Protobuf_Room_Leave_RESP();
ErrorCode errcode;
Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
@ -243,20 +272,22 @@ namespace AxibugEmuOnline.Server
{
if (room.Leave(_c, out errcode, out bHadRoomStateChange))
{
resp.RoomID = msg.RoomID;
resp.RoomID = RoomID;
}
}
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomLeave, (int)errcode, ProtoBufHelper.Serizlize(resp));
Protobuf_Room_MyRoom_State_Change(msg.RoomID);
Protobuf_Room_MyRoom_State_Change(RoomID);
if (errcode == ErrorCode.ErrorOk && bHadRoomStateChange)
SendRoomStateChange(room);
SendRoomUpdateToAll(room.RoomID, 1);
if (room.GetPlayerCount() < 1)
{
RemoveRoom(room.RoomID);
SendRoomUpdateToAll(room.RoomID, 1);
}
else
SendRoomUpdateToAll(room.RoomID, 0);
}
public void OnHostPlayerUpdateStateRaw(Socket sk, byte[] reqData)