Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions evtwebsocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Conn struct {
ws *websocket.Conn
url string
subprotocol string
origin string
closed bool
msgQueue []Msg
pingTimer time.Time
Expand All @@ -34,13 +35,14 @@ 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/")
c.ws, err = websocket.Dial(url, subprotocol, origin)
if err != nil {
return err
}
Expand Down Expand Up @@ -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)
Expand Down