Skip to content

Commit 41f2f2d

Browse files
authored
Merge pull request #47 from bminer/main
Added GetPort method (closes #46)
2 parents 8c18aef + e4c1916 commit 41f2f2d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

v2/lib.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,18 @@ func (w Window) GetChildProcessID() uint64 {
345345
return uint64(C.webui_get_child_process_id(C.size_t(w)))
346346
}
347347

348-
// SetPort sets a custom web-server network port to be used by WebUI.
348+
// GetPort returns the network port of the running window. If the window isn't
349+
// running, an error is returned.
350+
func (w Window) GetPort() (int, error) {
351+
port := int(C.webui_get_port(C.size_t(w)))
352+
if port == 0 {
353+
return 0, errors.New("error: failed to get port")
354+
}
355+
return port, nil
356+
}
357+
358+
// SetPort sets a custom web-server network port to be used by WebUI. Returns
359+
// true if the port is free and usable by WebUI.
349360
func (w Window) SetPort(port uint) bool {
350361
return bool(C.webui_set_port(C.size_t(w), C.size_t(port)))
351362
}

0 commit comments

Comments
 (0)