func (s *Socket) Connect(event js.Value) error {
	if s.isOpen() {
		return nil
	}
	f, err := ui.NewForm(s.dom.QuerySelectorAll, event)
	if err != nil {
		return err
	}
	url := s.webSocketURL(*f)
	s.releaseWebSocketJsFuncs()
	errC := make(chan error, 1)
	s.jsFuncs.onOpen = s.dom.NewJsFunc(s.onOpen(errC))
	s.jsFuncs.onClose = s.dom.NewJsEventFunc(s.onClose)
	s.jsFuncs.onError = s.dom.NewJsFunc(s.onError(errC))
	s.jsFuncs.onMessage = s.dom.NewJsEventFunc(s.onMessage)
	s.webSocket = s.dom.NewWebSocket(url)
	s.webSocket.Set("onopen", s.jsFuncs.onOpen)
	s.webSocket.Set("onclose", s.jsFuncs.onClose)
	s.webSocket.Set("onerror", s.jsFuncs.onError)
	s.webSocket.Set("onmessage", s.jsFuncs.onMessage)
	return <-errC
}
// Connect establishes the websocket connection if it has not yet been established.
Connect establishes the websocket connection if it has not yet been established.
// Connect establishes the websocket connection if it has not yet been established .
func (s *Socket) Connect(event js.Value) error {
	if s.isOpen() {
		return nil
	}
	f, err := ui.NewForm(s.dom.QuerySelectorAll, event)
	if err != nil {
		return err
	}
	url := s.webSocketURL(*f)
	s.releaseWebSocketJsFuncs()
	errC := make(chan error, 1)
	s.jsFuncs.onOpen = s.dom.NewJsFunc(s.onOpen(errC))
	s.jsFuncs.onClose = s.dom.NewJsEventFunc(s.onClose)
	s.jsFuncs.onError = s.dom.NewJsFunc(s.onError(errC))
	s.jsFuncs.onMessage = s.dom.NewJsEventFunc(s.onMessage)
	s.webSocket = s.dom.NewWebSocket(url)
	s.webSocket.Set("onopen", s.jsFuncs.onOpen)
	s.webSocket.Set("onclose", s.jsFuncs.onClose)
	s.webSocket.Set("onerror", s.jsFuncs.onError)
	s.webSocket.Set("onmessage", s.jsFuncs.onMessage)
	return <-errC
}
func ( s * Socket ) Connect ( event js . Value ) error { if s . isOpen ( ) { return nil } f , err := ui . NewForm ( s . dom . QuerySelectorAll , event ) if err != nil { return err } url := s . webSocketURL ( * f ) s . releaseWebSocketJsFuncs ( ) errC := make ( chan error , 1 ) s . jsFuncs . onOpen = s . dom . NewJsFunc ( s . onOpen ( errC ) ) s . jsFuncs . onClose = s . dom . NewJsEventFunc ( s . onClose ) s . jsFuncs . onError = s . dom . NewJsFunc ( s . onError ( errC ) ) s . jsFuncs . onMessage = s . dom . NewJsEventFunc ( s . onMessage ) s . webSocket = s . dom . NewWebSocket ( url ) s . webSocket . Set ( " " , s . jsFuncs . onOpen ) s . webSocket . Set ( " " , s . jsFuncs . onClose ) s . webSocket . Set ( " " , s . jsFuncs . onError ) s . webSocket . Set ( " " , s . jsFuncs . onMessage ) return <- errC }
Connect establishes the websocket connection if it has not yet been established.
Connect establishes the websocket connection if it has not yet been established .