Skip to content
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

Use enum replace magic number in Event opeation #1448

Open
1Ckpwee opened this issue Sep 13, 2023 · 0 comments
Open

Use enum replace magic number in Event opeation #1448

1Ckpwee opened this issue Sep 13, 2023 · 0 comments

Comments

@1Ckpwee
Copy link

1Ckpwee commented Sep 13, 2023

I was confused when I debug here, I didn't understand what the different operations meant until I notice the comments.
Maybe define enum for every operation and replace magic number can make it easy to understand.
e.g.

// use iota if operation number is progressive
const (
	_ = iota
	xxxOperation
)
// or 
const (
	PingOperation = 1
	ReconnectOperation = 7
	InvalidSessionOperation = 9
	HeartbeatOperation = 11
)
...
switch e.Operation {
	case PingOperation:
		//...
	case ReconnectOperation:
		//...
	default:
		//...
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant