2017-12-08 08:31:45 +00:00
|
|
|
package probe
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"git.loafle.net/commons_go/logging"
|
|
|
|
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
|
|
|
|
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
|
|
|
|
"git.loafle.net/overflow/overflow_probes/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SocketHandlers struct {
|
|
|
|
cwfc.SocketHandlers
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.Response) {
|
|
|
|
logging.Logger().Info(fmt.Sprintf("Probe: client has been connected res[%v]", res))
|
|
|
|
|
|
|
|
encryptionKey := res.Header.Get(oocmp.HTTPResponseHeaderKey_Probe_SetEncryptionKey)
|
|
|
|
config.EncryptionKey = &encryptionKey
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
2017-12-09 08:41:43 +00:00
|
|
|
logging.Logger().Info(fmt.Sprintf("Probe: client has been disconnected soc[%v]", soc))
|
2017-12-08 08:31:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func newSocketHandler() cwfc.SocketHandler {
|
|
|
|
return &SocketHandlers{}
|
|
|
|
}
|