magefree / magefree/mage

Server: some commands uses duplicated threads (matchQuit, etc)

Open
#11,463 0 comments 0 reactions 1 assignee Claimed by @JayDi85 View on GitHub
refactoring server
Dominant language
Java
Stars
2.4k
Forks
940
Avg merge
2d 12h
Merged PRs (30d)
160

Description

Example for `MageServerImpl::matchQuit` -- it uses a strange code with double threads.
* user call `matchQuit`;
* server creates new thread 1 to execute it;
* thread 1 check user session and creates another thread 2 to continue;
* thread 2 execute real quite game code;
![shot_231125_123439](https://github.com/magefree/mage/assets/8344157/fd4beee8-ef88-4dba-bb2f-f96372ef60d9)

Code added by [that commit](https://github.com/magefree/mage/commits/fea9dfe8f8f144a29dd6d5e099bce660b8d86617). Looks like it was added for error catching, but it will never work -- `execute` hides all errors, so `handleException` never called here. Maybe it require `submit` instead `execute` and result waiting -- then error catching will be workable and double threads logic will be fine with it.

Correct usage from `MageServerImpl::deckSave`:
![shot_231125_123855](https://github.com/magefree/mage/assets/8344157/5b9b00b2-902f-423e-a6e3-0d0f74f434bf)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.