Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not catching all events from server #32

Open
apooslr opened this issue Mar 8, 2018 · 3 comments
Open

Not catching all events from server #32

apooslr opened this issue Mar 8, 2018 · 3 comments

Comments

@apooslr
Copy link

apooslr commented Mar 8, 2018

Hello,

I am connection to a server like so:

m.client, err = gosocketio.Dial(gosocketio.GetUrl(m.hostname, 9000, false), transport.GetDefaultWebsocketTransport())

m.client.On(<event-name>, m.updates)
m.client.On(<another-event>, m.updates)

And I am able to connecto to the sockat and receive one event, the first one, but for some reason I am not catching any other events. What am I missing??

@guhan121
Copy link

guhan121 commented Apr 19, 2018

i think this is a bug,
you add event method by func (m *methods) On(method string, f interface{}) error
but if you connect ok, and server send event (like "hello" )before program call On("hello",func), it conn't find the method.

so i add init client it. init client --> On() --> dial 。

func InitConnect() (*Client) {
	c := &Client{}
	c.initChannel()
	c.initMethods()
	return c
}
func Dial(url string, tr transport.Transport ,c *Client) (error) {

	var err error
	c.conn, err = tr.Connect(url)
	if err != nil {
		return err
	}

	go inLoop(&c.Channel, &c.methods)
	go outLoop(&c.Channel, &c.methods)
	go pinger(&c.Channel)

	return nil
}

@apooslr
Copy link
Author

apooslr commented Apr 26, 2018

Thank you for the suggestion! I actually had it configured properly, the problem was the server I was connecting to required further authentication to allow me to get the other events.

@mtfelian
Copy link

I created a fork of that, you can use it.
https://github.com/mtfelian/golang-socketio

The code were heavily refactored.

Pull requests appreciated, i don't have much time for implementing new features but i will review and participate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants