Commit 096757c8 authored by ibuler's avatar ibuler

[Update] 修改timeout

parent af8cfdaf
......@@ -4,6 +4,7 @@ import (
"net"
"net/http"
"path/filepath"
"time"
"github.com/gorilla/mux"
"github.com/kataras/neffos"
......@@ -17,26 +18,30 @@ var (
httpServer *http.Server
)
var wsEvents = neffos.Namespaces{
"ssh": neffos.Events{
neffos.OnNamespaceConnected: OnNamespaceConnected,
neffos.OnNamespaceDisconnect: OnNamespaceDisconnect,
neffos.OnRoomJoined: func(c *neffos.NSConn, msg neffos.Message) error {
return nil
var wsEvents = neffos.WithTimeout{
ReadTimeout: 24 * time.Hour,
WriteTimeout: 24 * time.Hour,
Namespaces: neffos.Namespaces{
"ssh": neffos.Events{
neffos.OnNamespaceConnected: OnNamespaceConnected,
neffos.OnNamespaceDisconnect: OnNamespaceDisconnect,
neffos.OnRoomJoined: func(c *neffos.NSConn, msg neffos.Message) error {
return nil
},
neffos.OnRoomLeft: func(c *neffos.NSConn, msg neffos.Message) error {
return nil
},
"data": OnDataHandler,
"resize": OnResizeHandler,
"host": OnHostHandler,
"logout": OnLogoutHandler,
"token": OnTokenHandler,
},
neffos.OnRoomLeft: func(c *neffos.NSConn, msg neffos.Message) error {
return nil
"elfinder": neffos.Events{
neffos.OnNamespaceConnected: OnELFinderConnect,
neffos.OnNamespaceDisconnect: OnELFinderDisconnect,
},
"data": OnDataHandler,
"resize": OnResizeHandler,
"host": OnHostHandler,
"logout": OnLogoutHandler,
"token": OnTokenHandler,
},
"elfinder": neffos.Events{
neffos.OnNamespaceConnected: OnELFinderConnect,
neffos.OnNamespaceDisconnect: OnELFinderDisconnect,
},
}
......@@ -48,6 +53,17 @@ func StartHTTPServer() {
}
sshWs.OnUpgradeError = func(err error) {
}
sshWs.OnConnect = func(c *neffos.Conn) error {
if c.WasReconnected() {
logger.Debugf("Connection reconnected, with tries: %d", c.ID(), c.ReconnectTries)
} else {
logger.Debug("A new ws connection arrive")
}
return nil
}
sshWs.OnDisconnect = func(c *neffos.Conn) {
logger.Debug("Ws connection disconnect")
}
router := mux.NewRouter()
fs := http.FileServer(http.Dir(filepath.Join(conf.RootPath, "static")))
......
......@@ -24,10 +24,9 @@ import (
func OnNamespaceConnected(c *neffos.NSConn, msg neffos.Message) error {
// 首次连接 1.获取当前用户的信息
cc := c.Conn
logger.Debug("Web terminal on connect event trigger")
if cc.WasReconnected() {
logger.Debugf("Web terminal reconnected, with tries: %d", cc.ID(), cc.ReconnectTries)
} else {
logger.Debug("Web terminal on connect event trigger")
}
request := cc.Socket().Request()
header := request.Header
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment