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

client/wasm: Added a new parameter to pass the HOST #72

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions client/wasm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ func main() {

func NewClient() js.Func {
return js.FuncOf(func(this js.Value, args []js.Value) any {
if len(args) != 2 || (args[0].String() == "" || args[1].String() == "") {
return fmt.Errorf("requires 2 parameters: room and name")
if len(args) != 3 || (args[0].String() == "" || args[1].String() == "" || args[2].String() == "") {
return fmt.Errorf("requires 3 parameters: host, room and name")
}
var (
err error
room = args[0].String()
name = args[1].String()
hostURL = "localhost:5555"
hostURL = args[0].String()
room = args[1].String()
name = args[2].String()
screenW = 288
screenH = 240
)
Expand Down
Binary file modified server/assets/wasm/maze-wars.wasm
Binary file not shown.
3 changes: 2 additions & 1 deletion server/templates/views/game/game.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
var currentUrl = new URL(document.referrer);
const urlParams = new URLSearchParams(currentUrl.search);

const host = currentUrl.host
const room = currentUrl.pathname.split("/")[2]
const name = urlParams.get("name")
const err = new_client(room, name);
const err = new_client(host, room, name);
if (err != null) {
console.log("error",err)
}
Expand Down