antoniodipinto / ikisocket

🧬 WebSocket wrapper with event management for Fiber https://github.com/gofiber/fiber. Based on Fiber WebSocket and inspired by Socket.io
MIT License
123 stars 21 forks source link

ikisocket.New() behavior in chat example #5

Closed sebastianbuechler closed 3 years ago

sebastianbuechler commented 3 years ago

After upgrading to V2 I wanted to try out the chat example.

First, there is a small error for the middleware because of the upgrade. It should now look like this:

    // Setup the middleware to retrieve the data sent in first GET request
    app.Use(func(c *fiber.Ctx) error {
        c.Locals("user_id", c.Query("user_id"))
        return c.Next()
    })

In the example all the callbacks defined with ikisocket.On() work as expected. However, everything inside the ikisocket.New() function gets called only after the connection is closed.

For example:

Also, the callbacks defined for kws.OnConnect and kws.OnMessage do not fire in the example (probably because they are also part of the ikisocket.New() callback.

Any idea on why the ikisocket.New() does not behave properly? Do you experience the same behavior?

antoniodipinto commented 3 years ago

Hi @sebastianbuechler yesterday I made a test before pushing and everything was working fine. Probably the test was not working as expected. I will check and also I will update the README.md file after that. Hopefully tomorrow night everything will be fine

Thank you for this issue

antoniodipinto commented 3 years ago

Also, the callbacks defined for kws.OnConnect and kws.OnMessage do not fire in the example (probably because they are also part of the ikisocket.New() callback.

Yes, that's should be the issue.

sebastianbuechler commented 3 years ago

@antoniodipinto thanks for your reply.

Additionally, the port notation in the example should be adjusted to app.Listen(":3000") since the new version of fiber requires this.

antoniodipinto commented 3 years ago

Everything should be fixed now with the new update