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

调试器支持多个调试器同时调试不同的热更程序 #673

Merged
merged 10 commits into from
Mar 18, 2022

Conversation

Endures
Copy link
Contributor

@Endures Endures commented Mar 16, 2022

调试多人联网项目时,本地经常会开启2个以上的客户端进行联机调式。如果使用同一个端口会造成端口占用,只能附加一个客户端。本pr提供了一个解决方案。

示例及使用方法:

  • 示例环境
    示例在本地开启了2个Unity编辑器
    捕获
    对应的进程信息为
    捕获1
  • 为新增委托ILRuntime.Runtime.Debugger.DebuggerServer.GetProjectNameFunction赋值以提供项目名称
    例如可使用如下代码提供项目名称
var path = Application.dataPath.Remove(Application.dataPath.LastIndexOf("/Assets"));
var lastIndexOfSeparator = path.LastIndexOf('/');
var projectName = path.Substring(lastIndexOfSeparator + 1);
ILRuntime.Runtime.Debugger.DebuggerServer.GetProjectNameFunction = () => projectName;
  • 将开启调试服务的接口修改为appdomain.DebugService.StartDebugService(56000, true);
    第二个参数为新增参数。false表示使用现有模式,true表示启用广播模式,56000为udp广播端口,原来的tcp端口根据当前进程ID计算。默认值为false以兼容现有代码
  • 点击Visual Studio新增菜单项Attach to ILRuntime in LAN
    捕获2
    弹出实例选择窗口
    捕获3
    选择其中一个实例即可开始对目标的调试。
  • Visual Studio扩展默认监听udp端口56000。可在工具->选项窗口中自定义这个端口
    捕获4
  • 如果没有多目标调试需求可完全无视新增的API,不会影响现有功能

@liiir1985
Copy link
Collaborator

由于ILRuntime现在也有外国的用户,因此主Repo中的功能应默认提供英语,然后中文以多语言的方式提供更为妥当

@liiir1985
Copy link
Collaborator

另外,你提供的这个模式更优,应作为默认模式,UI入口可以把不保留原来的那个菜单入口,而是在新的这个选择实例的UI左下角加入一个按钮,Enter ip。点击后才走原来的那个逻辑

@Endures
Copy link
Contributor Author

Endures commented Mar 17, 2022

1.把原有的输入ip和port的模式作为默认模式是出于这样的考虑:如果没有多实例调试需求的话可以完全无视这个新模式,也不会改变原来的操作习惯。另外如果需要点击“选择实例”窗口里面的一个按钮才弹出Enter ip界面的话,那么有需要输入ip需求的用户需要先点击菜单项再点击一个按钮,对他们来说是不是太麻烦了。
2.关于英文文档的问题,我本人英语不好,也不知道应该怎么操作,可不可以麻烦你帮我弄一下。

@liiir1985
Copy link
Collaborator

多语言的我来搞OK
DebuggerServer.Start的时候,默认使用新模式,也就是默认开启广播,只有特殊需求需要连接非本机IP时才需要Enter IP,我觉得这样应该更合理一些

@Endures
Copy link
Contributor Author

Endures commented Mar 17, 2022

@liiir1985 如果你确认这样修改更合理的话我就开始动手改了

@liiir1985
Copy link
Collaborator

@liiir1985 如果你确认这样修改更合理的话我就开始动手改了

嗯,我觉得这样对用户来说体验更佳,也能避免56000被某些软件占用导致连不上的尴尬境地

@liiir1985
Copy link
Collaborator

@Endures 另外,56000这个广播端口也改为默认参数吧
也就是DebuggerServer的Start,支持无参数,默认使用56000广播

Endures added 2 commits March 18, 2022 11:12
选择目标实例窗口增加一个按钮进入输入地址和端口窗口
DebugService.StartDebugService方法port参数默认值为56000,boardcastDebuggerInfo参数默认值为true
@Endures
Copy link
Contributor Author

Endures commented Mar 18, 2022

@liiir1985 改完了,但没有通过Build Test。
报错在:
_udpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, false);
Build Test环境不支持socket非独占?

@liiir1985
Copy link
Collaborator

at ILRuntimeTest.TestBase.TestSession.Load(String assemblyPath, Boolean useRegister) in /home/runner/work/ILRuntime/ILRuntime/ILRuntimeTestBase/TestBase/TestSession.cs:line 40
这块DebuggerServer.Start 周围try catch一下在test的时候忽略debugger的启动吧

@Endures
Copy link
Contributor Author

Endures commented Mar 18, 2022

@liiir1985 已修改

@liiir1985 liiir1985 merged commit 4c841de into Ourpalm:master Mar 18, 2022
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

Successfully merging this pull request may close these issues.

2 participants