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

Can send values to backend? #54

Open
zerofelx opened this issue Jan 9, 2020 · 1 comment
Open

Can send values to backend? #54

zerofelx opened this issue Jan 9, 2020 · 1 comment

Comments

@zerofelx
Copy link

zerofelx commented Jan 9, 2020

Hello
I can send strings, booleans, ints or another value or variable to backend?
I use the events but I don't understand what is the method to send values, I only can run a code whit a event but without a value from the Frontend

Example:
I create a form, the form get Username and password

When click "Send" with a event to backend, the event run the code but don't send the values to golang

How I compare this values with the values in the backend?

Or how i can send the values?

Thanks! :D

@zerofelx
Copy link
Author

zerofelx commented Jan 10, 2020

Temporal solution:

Javascript Code:

ws.send(JSON.stringify({
event: "Chrome",
variables: v
})) (v is a parameter of a function)

I added Variables string json:"variables"`` into Event struct
I added a global variable into gotron.go var UserVar = make(chan Event) after to Event struct
In function "onSocket" after of:

//Handle Message
err = json.Unmarshal(message, &event)
errz.Fatal(err, "Unmashal: ")
logger.Debug().Msgf("ElectronSocket: [received] %+v", event)

I added:
go func() { UserVar <- event }()

I call the variable in my code this way:
window.On(&Evento, func(bin []byte) {
item := <-gotron.UserVar
fmt.Println(item.Variables)
})

^^

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

No branches or pull requests

1 participant