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

View File

@ -1,6 +1,9 @@
package probe package probe
import ( import (
"fmt"
"git.loafle.net/commons_go/logging"
"git.loafle.net/commons_go/websocket_fasthttp/websocket" "git.loafle.net/commons_go/websocket_fasthttp/websocket"
oogws "git.loafle.net/overflow/overflow_gateway_websocket/servlet" oogws "git.loafle.net/overflow/overflow_gateway_websocket/servlet"
oogwsub "git.loafle.net/overflow/overflow_gateway_websocket/subscribe" 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) { func (sh *SubscriberHandlers) OnSubscribe(channel string, message oos.SubscribeMessage) {
for _, uid := range message.Targets { switch message.TargetType {
if soc := sh.GetSocket(uid); nil != soc { case oos.PROBE:
soc.WriteMessage(websocket.TextMessage, message.Message) 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() { func (sh *SubscriberHandlers) Validate() {
sh.SubscriberHandlers.Validate() sh.SubscriberHandlers.Validate()
} }