-
hi, My only question is how to enable Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
norazlan
May 10, 2024
Replies: 2 comments
-
I think I got this, #49 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
norazlan
-
package main
import (
"os"
"os/signal"
"syscall"
"github.com/zishang520/engine.io/v2/log"
"github.com/zishang520/engine.io/v2/types"
"github.com/zishang520/socket.io/v2/socket"
)
func main() {
log.DEBUG = true
c := socket.DefaultServerOptions()
// 开启Session功能。
// Enable Session function.
c.SetConnectionStateRecovery(&socket.ConnectionStateRecovery{})
// c.SetAllowEIO3(true)
// c.SetServeClient(true)
// c.SetCors(&types.Cors{
// Origin: "http://127.0.0.1:8000",
// Credentials: true,
// })
httpServer := types.CreateServer(nil)
io := socket.NewServer(httpServer, c)
io.On("connection", func(clients ...interface{}) {
client := clients[0].(*socket.Socket)
client.On("disconnect", func(...interface{}) {
// utils.Log().Success("/ test disconnect")
})
})
httpServer.Listen("127.0.0.1:3000", nil)
exit := make(chan struct{})
SignalC := make(chan os.Signal)
signal.Notify(SignalC, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
for s := range SignalC {
switch s {
case syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT:
close(exit)
return
}
}
}()
<-exit
io.Close(nil)
os.Exit(0)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think I got this, #49