Hi, not sure about the WebSocket question, but if you are just trying to interpret the declaration, I can help with that.
So it means onmessage is a function variable and that function takes an Event object as a param and returns a dynamic object, and the ? at the end means the whole thing can be null...
onmessage = null // is OK
onmessage = { event: Event -> doSomethingWithEvent(event); return anything;} // is OK
So the dynamic anything can be any type of object in Javascript, so could be a string, an int or a null (I think)... and, I believe you don't actually need to return anything (leave out the return statement), as then you are actually returning a Unit, which is acceptable for dynamic... so { event: Event -> doSomethingWithEvent(event)} should be fine too...
Hope it helps 🙂