illud
(Illud)
September 1, 2020, 9:19pm
1
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",
})
}
lutzhorn
(Lutz Horn)
September 2, 2020, 11:52am
2
Is this working? If not, what does not work?
illud
(Illud)
September 2, 2020, 1:28pm
3
Hello, the socket.io code is mising becouse i don’t know how yo implement .
lutzhorn
(Lutz Horn)
September 2, 2020, 3:00pm
4
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
.
illud
(Illud)
September 2, 2020, 3:08pm
5
Yeah, but i have to used it with gin gonic and has to be in anotehr function
lutzhorn
(Lutz Horn)
September 2, 2020, 3:09pm
6
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.
system
(system)
Closed
December 1, 2020, 3:09pm
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.