Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions GenOnlineService/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,11 @@ public class UserSession

private string ACExeCRC = String.Empty;

// Matchmaking data
public UInt16 MatchmakingPlaylistID = 0;
public ConcurrentList<int> MatchmakingMapIndicies = new();
// Matchmaking data
public UInt16 MatchmakingPlaylistID = 0;
public ConcurrentList<int> MatchmakingMapIndicies = new();
internal bool IsRegisteredForMatchmaking { get; set; } = false;
internal SemaphoreSlim MatchmakingStateLock { get; } = new(1, 1);

// NOTE: These are not set on login, only when in quickmatch!
public UInt32 ExeCRC = 0;
Expand Down Expand Up @@ -1356,11 +1358,11 @@ public static async Task FullyDestroyPlayerSession(Int64 user_id, UserSession? u

await lobbyManager.CleanupUserLobbiesNotStarted(user_id);

// remove from any matchmaking
if (userData != null)
{
MatchmakingManager.DeregisterPlayer(userData);
}
// remove from any matchmaking
if (userData != null)
{
await MatchmakingManager.DeregisterPlayer(userData);
}

// TODO: Client needs to handle this... itll start returning 404
}
Expand Down Expand Up @@ -2543,9 +2545,11 @@ public enum EWebSocketMessageID
SOCIAL_CANT_ADD_FRIEND_LIST_FULL = 38,
PROBE_RESP = 39,
AC_REGISTER_PLAYER = 40,
AC_DEREGISTER_PLAYER = 41,
WS_KEEPALIVE = 42,
WS_KEEPALIVE_CLIENT = 43
AC_DEREGISTER_PLAYER = 41,
WS_KEEPALIVE = 42,
WS_KEEPALIVE_CLIENT = 43,
MATCHMAKING_ACTION_REQUEUE = 44,
MATCHMAKING_ACTION_SETUP_PROGRESS = 45
};

public static class UserPresence
Expand Down Expand Up @@ -2653,8 +2657,16 @@ public class WebSocketMessage_NameChange : WebSocketMessage
public string name { get; set; } = String.Empty;
}

public class WebSocketMessage_FullMeshConnectivityCheckResponseFromUser : WebSocketMessage
{
public class WebSocketMessage_FullMeshConnectivityCheckRequest : WebSocketMessage
{
public Int64 mesh_check_id { get; set; }
public int attempt { get; set; }
}

public class WebSocketMessage_FullMeshConnectivityCheckResponseFromUser : WebSocketMessage
{
public Int64 mesh_check_id { get; set; }
public int attempt { get; set; }
public List<Int64> connectivity_map { get; set; } = new();
}

Expand Down Expand Up @@ -2829,4 +2841,9 @@ public class WebSocketMessage_MatchmakerStartGame : WebSocketMessage

}

}
public class WebSocketMessage_MatchmakerSetupProgress : WebSocketMessage
{
public int timeout_ms { get; set; }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,20 @@ public void Put_Widen()
}
}

[HttpDelete]
[Authorize(Roles = "GameClient")]
public void Delete()
[HttpDelete]
[Authorize(Roles = "GameClient")]
public async Task Delete()
{
Int64 user_id = TokenHelper.GetUserID(this);
EUserSessionType sessionType = TokenHelper.GetSessionType(this);
if (user_id != -1 && SessionHelpers.SessionTypeHasAccessTo(sessionType, ESessionAccessType.Gameplay))
{
UserSession? playerSession = WebSocketManager.GetSessionFromUser(user_id, sessionType);

if (playerSession != null)
{
MatchmakingManager.DeregisterPlayer(playerSession);
}
if (playerSession != null)
{
await MatchmakingManager.DeregisterPlayer(playerSession);
}
}
}

Expand Down
22 changes: 2 additions & 20 deletions GenOnlineService/Controllers/WebSocket/WebSocketController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -843,25 +843,7 @@ private async Task ProcessWSMessage(UserWebSocketInstance sourceWS, UserSession
lobbyInfo.StartFullMeshConnectivityCheck();

// start full mesh connectivity checks
WebSocketMessage_Simple startCommand = new WebSocketMessage_Simple();
startCommand.msg_id = (int)EWebSocketMessageID.FULL_MESH_CONNECTIVITY_CHECK_RESPONSE;

// Serialize once before broadcasting
byte[] bytesJSON = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(startCommand));

foreach (LobbyMember lobbyMember in lobbyInfo.Members)
{
if (lobbyMember != null)
{
if (lobbyMember.GetSession().TryGetTarget(out UserSession? sess))
{
if (sess != null)
{
sess.QueueWebsocketSend(bytesJSON);
}
}
}
}
lobbyInfo.SendFullMeshConnectivityCheckRequestToMembers();
}
else if (msgID == EWebSocketMessageID.FULL_MESH_CONNECTIVITY_CHECK_RESPONSE)
{
Expand All @@ -875,7 +857,7 @@ private async Task ProcessWSMessage(UserWebSocketInstance sourceWS, UserSession
Lobby? lobby = _lobbyManager.GetLobby(sourceUserSession.currentLobbyID);
if (lobby != null)
{
await lobby.StoreFullMeshConnectivityResponse(sourceUserSession.m_UserID, fullMeshMsg.connectivity_map);
await lobby.StoreFullMeshConnectivityResponse(sourceUserSession.m_UserID, fullMeshMsg);
}
}
}
Expand Down
Loading
Loading