-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor of matchmaking_utils.go #28
base: main
Are you sure you want to change the base?
Conversation
… unregister notification on session remove
Is there a reason you didn't use |
Because when I started implementing it I didn't know what I wanted yet. If stuff works it can be migrated. |
Reviewed EDIT: It's actually possible to lock the mutexmap manually by calling |
Ready for review after leaving the server running overnight and not noticing any issues nor stuck rooms in MK7. |
// FindOtherConnectionID searches a connection ID on the session that isn't the given one | ||
// Returns 0 if no connection ID could be found | ||
func FindOtherConnectionID(excludedConnectionID uint32, gatheringID uint32) uint32 { | ||
func findOtherConnectionIDImpl(excludedConnectionID uint32, gatheringID uint32) uint32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of the way these Impl
functions are named/handled, though I understand why the implementation is separate from the exported function
This Impl
convention could be refactored out by moving all of this out of the global scope and moving it to a struct, and having the functions currently named with Impl
as just unexported methods
Something like
package main
import "fmt"
type sessionsManager struct{}
func (sm *sessionsManager) FindOtherConnectionID() {
fmt.Println("Exported")
sm.findOtherConnectionID()
}
func (sm *sessionsManager) findOtherConnectionID() {
fmt.Println("Unexported")
}
func main() {
sm := &sessionsManager{}
sm.FindOtherConnectionID()
// Prints both Exported and Unexported
}
@DaniElectra thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for DaniElectra response, it's also possible to not export the functions by just making them lowercase. But it may be better to have the sessions maps in the struct instead of being something global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's also possible to not export the functions by just making them lowercase
That's already how it's implemented, both in your PR and my suggestion? My comment was about exported vs unexported, it was on the naming conventions of the methods
It's clear you want to export a function which calls an implementation, without exposing the implementation itself. This is fine, I'm just not a fan of the way the functions themselves are named currently. So my suggestion was to bring them into a "manager" style struct, renaming the Impl
functions to just have the same name as the exported one but be unexported
Though now that I think about it, why is the implementation functions separate now? I see elsewhere you call the Impl
functions directly, but since both the exported and Impl
functions have the same signatures why not just call the exported function directly and not have this separation?
But it may be better to have the sessions maps in the struct instead of being something global.
My example was minimal to try and get the point across but yes ideally in this example everything to do with sessions would be contained in the manager (the lock, the map, etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The impl is needed to be able to call functions without locking the sessions lock again. I will move everything to a struct after I figure out the stuck gathering issues.
I just added the
Here is what I think is happening:
This theory explains both observations:
|
That all sounds logical to me. Barring any new observations or issues with that implementation I think that's fine? |
From my observations the NewParticipant notification is only sent to the owner in MK7. This has to be verified with other games (cc @shutterbug2000 ) |
This change implements the following things:
SessionManagementDebugLog
boolean to allow debugging general session state.GatheringFlags.DisconnectChangeOwner
flag. Only the owner is changed and the host is left untouched.UpdateSessionURL
andUpdateSessionHost
. Only the host is changed and the owner is left untouched.GatheringUnregistered
event when a gathering is deleted.I will implement this change in the CTGP-7 server to investigate the effects. If they are positive will convert from a draft to a PR.