From c5aded02614f8abc62f96ba6a629f8c4c43e01ae Mon Sep 17 00:00:00 2001 From: N4r35h Date: Tue, 17 Sep 2024 10:56:18 +0530 Subject: [PATCH 1/2] expose origin --- evtwebsocket.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/evtwebsocket.go b/evtwebsocket.go index 301aee1..73c2198 100644 --- a/evtwebsocket.go +++ b/evtwebsocket.go @@ -19,6 +19,7 @@ type Conn struct { ws *websocket.Conn url string subprotocol string + origin string closed bool msgQueue []Msg pingTimer time.Time @@ -34,10 +35,11 @@ type Msg struct { // host provided in the url parameter. // Note that all the parameters of the structure // must have been set before calling it. -func (c *Conn) Dial(url, subprotocol string) error { +func (c *Conn) Dial(url, subprotocol, origin string) error { c.closed = true c.url = url c.subprotocol = subprotocol + c.origin = origin c.msgQueue = []Msg{} var err error c.ws, err = websocket.Dial(url, subprotocol, "http://localhost/") @@ -120,7 +122,7 @@ func (c *Conn) close() { c.closed = true if c.Reconnect { for { - if err := c.Dial(c.url, c.subprotocol); err == nil { + if err := c.Dial(c.url, c.subprotocol, c.origin); err == nil { break } time.Sleep(time.Second * 1) From 06d4439a181108d1b2d6763e2bb78bafad6aa55c Mon Sep 17 00:00:00 2001 From: N4r35h Date: Thu, 19 Sep 2024 20:44:35 +0530 Subject: [PATCH 2/2] Update evtwebsocket.go --- evtwebsocket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evtwebsocket.go b/evtwebsocket.go index 73c2198..0eef14f 100644 --- a/evtwebsocket.go +++ b/evtwebsocket.go @@ -42,7 +42,7 @@ func (c *Conn) Dial(url, subprotocol, origin string) error { c.origin = origin c.msgQueue = []Msg{} var err error - c.ws, err = websocket.Dial(url, subprotocol, "http://localhost/") + c.ws, err = websocket.Dial(url, subprotocol, origin) if err != nil { return err }