gotron
gotron copied to clipboard
ws.onmessage not called
Hey
Been testing the example and the function
ws.onmessage = function(e) {
console.log("Message received: " + e.data);
}
will not be called in my javascript file. I can not see the mistake?
Solved! Problem is if you have code like this the send event will not happen quickly enough. For the frontend to receive. So fix was to add a callback function :D window.Send(&event)
window.On(&gotron.Event{Event: "event-name"}, func(bin []byte) { var event2 CustomEvent json.Unmarshal(bin, &event2) fmt.Println("EVENT Name:", event2.Event.Event) fmt.Println("EVENT AtrNameInFrontend:", event2.AtrNameInFrontend) callEvent(window) })