fix(client): 多开 Unity 时优先连接当前项目实例#45
Open
daixian wants to merge 1 commit into
Open
Conversation
Owner
|
This looks like a valid PR for Unity multi-instance scenarios. Please provide the actual test results following your changes; if the outcome meets expectations, I will merge the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
当同时运行多个 Unity Editor 实例时,Python 客户端原本仅根据注册表中的
last_active心跳时间选择实例,优先连接最近更新心跳的 Unity。但各个 Unity 实例会独立、周期性地更新心跳,因此“最新心跳”只取决于客户端发起连接时各实例的心跳更新时间,并不能代表当前命令所属的项目。随着不同实例交替更新心跳,同一工作目录下连续执行相同命令,也可能被自动路由到不同的 Unity 实例。
这会带来两个问题:
因此,自动发现应优先依据当前工作目录确定目标项目;只有找不到匹配项目时,才使用心跳时间选择其他可用实例。
修改内容
8090-8100端口扫描兜底逻辑。自动发现顺序
8090-8100端口。显式指定
url、port、target或version时的行为保持不变。验证
git diff --check检查通过。RegistryService确认注册表的数据结构。