This commit is contained in:
crusader 2018-03-19 17:05:43 +09:00
parent d747c231f8
commit f5f56d2924
2 changed files with 15 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import (
cwf "git.loafle.net/commons_go/websocket_fasthttp"
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
probeM "git.loafle.net/overflow/overflow_commons_go/modules/probe/model"
oogw "git.loafle.net/overflow/overflow_gateway_websocket"
oogweg "git.loafle.net/overflow/overflow_gateway_websocket/external/grpc"
"git.loafle.net/overflow/overflow_gateway_websocket/rpc"
// jwt "github.com/dgrijalva/jwt-go"
@ -82,6 +83,9 @@ func (sh *GatewayRPCHandlers) Handshake(socketCTX cwf.SocketContext, ctx *fastht
extensionsHeader = &fasthttp.ResponseHeader{}
extensionsHeader.Add(oocmp.HTTPResponseHeaderKey_Probe_SetEncryptionKey, probe.EncryptionKey)
socketCTX.SetAttribute(oogw.ClientTypeKey, oogw.PROBE)
socketCTX.SetAttribute(oogw.TargetIDKey, probeKey)
return probeKey, extensionsHeader
}

View File

@ -1,6 +1,9 @@
package probe
import (
"fmt"
"git.loafle.net/commons_go/logging"
"git.loafle.net/commons_go/websocket_fasthttp/websocket"
oogws "git.loafle.net/overflow/overflow_gateway_websocket/servlet"
oogwsub "git.loafle.net/overflow/overflow_gateway_websocket/subscribe"
@ -20,15 +23,18 @@ type SubscriberHandlers struct {
}
func (sh *SubscriberHandlers) OnSubscribe(channel string, message oos.SubscribeMessage) {
for _, uid := range message.Targets {
if soc := sh.GetSocket(uid); nil != soc {
soc.WriteMessage(websocket.TextMessage, message.Message)
switch message.TargetType {
case oos.PROBE:
for _, pid := range message.Targets {
if soc := sh.GetSocket(pid); nil != soc {
soc.WriteMessage(websocket.TextMessage, message.Message)
}
}
default:
logging.Logger().Warn(fmt.Sprintf("[PROBE] SubscriberHandler: Unknown TargetType %s", message.TargetType))
}
}
func (sh *SubscriberHandlers) Validate() {
sh.SubscriberHandlers.Validate()
}