fix: relaunch server on port change

This commit is contained in:
Anna 2020-11-05 19:49:38 -05:00
parent 4e81786a2a
commit 6276bea698
2 changed files with 13 additions and 2 deletions

View File

@ -61,8 +61,7 @@ namespace XIVChatPlugin {
this.Ui = new PluginUI(this);
this.Server = new Server(this);
this.Server.Spawn();
this.LaunchServer();
this.Interface.UiBuilder.OnBuildUi += this.Ui.Draw;
this.Interface.UiBuilder.OnOpenConfigUi += this.Ui.OpenSettings;
@ -76,6 +75,16 @@ namespace XIVChatPlugin {
});
}
public void LaunchServer() {
this.Server = new Server(this);
this.Server.Spawn();
}
public void RelaunchServer() {
this.Server.Dispose();
this.LaunchServer();
}
private byte ChangeChatChannelDetour(IntPtr a1, uint channel) {
// a1 + 0xfd0 is the chat channel byte (including for when clicking on shout)
this.Server.OnChatChannelChange(channel);

View File

@ -117,6 +117,8 @@ namespace XIVChatPlugin {
ushort realPort = (ushort)Math.Min(ushort.MaxValue, Math.Max(1, port));
this.plugin.Config.Port = realPort;
this.plugin.Config.Save();
this.plugin.RelaunchServer();
}
ImGui.Spacing();