How to use googollee/go-socket.io with gin gonic

So i want to know how to have socket.io and use it with gin gonic

package main

import (
"github.com/gin-gonic/gin"
"github.com/googollee/go-socket.io"
)
func main() {
    r := gin.Default()
    r.GET("/ping", socketioFunc)
    r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}

func socketioFunc(c *gin.Context) {
//SOCKET IO STOFF
	c.JSON(200, gin.H{
		"message": "pong",
	})
}

Is this working? If not, what does not work?

Hello, the socket.io code is mising becouse i don’t know how yo implement .

There are examples for how to use go-socket.io: https://github.com/googollee/go-socket.io#example. Maybe it is possible to register a socket-io Server with Gin as it is done with http.Handle in the example. But this would happen in main, not in socketioFunc.

Yeah, but i have to used it with gin gonic and has to be in anotehr function

Good luck.

Meaning: “I have to” will probably not be enough to convince the libraries to do something (what exactly?) they are not designed for.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.