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

Add keyword for starting the browser #84

Merged
merged 1 commit into from
Feb 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/servers.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Base.open(vis::Visualizer, args...; kw...) = open(vis.core, args...; kw...)

function Base.open(core::CoreVisualizer, port::Integer)
function Base.open(core::CoreVisualizer, port::Integer; start_browser = true)
@async WebIO.webio_serve(Mux.page("/", req -> core.scope), port)
url = "http://127.0.0.1:$port"
@info("Serving MeshCat visualizer at $url")
open_url(url)
start_browser && open_url(url)
end

function open_url(url)
Expand All @@ -24,7 +24,7 @@ function open_url(url)
end
end

function Base.open(core::CoreVisualizer; default_port=8700, max_retries=500)
function Base.open(core::CoreVisualizer; default_port=8700, max_retries=500, start_browser = true)
for port in default_port:(default_port + max_retries)
server = try
listen(port)
Expand All @@ -38,6 +38,6 @@ function Base.open(core::CoreVisualizer; default_port=8700, max_retries=500)
# some other process grabs the given port in between the close() above
# and the open() below. But it's unlikely and would not be terribly
# damaging (the user would just have to call open() again).
return open(core, port)
return open(core, port, start_browser = start_browser)
end
end