This commit is contained in:
crusader 2017-12-05 14:40:31 +09:00
parent c3cd65f72d
commit 6614bd5489
4 changed files with 8 additions and 14 deletions

View File

@ -1,13 +1,15 @@
package server
import (
crpj "git.loafle.net/commons_go/rpc/protocol/json"
crr "git.loafle.net/commons_go/rpc/registry"
"git.loafle.net/commons_go/rpc/server"
)
func newRPCServletHandler(rpcInvoker crr.RPCInvoker) server.ServletHandler {
func NewRPCServletHandler(rpcInvoker crr.RPCInvoker) server.ServletHandler {
sh := &RPCServletHandlers{}
sh.RPCInvoker = rpcInvoker
sh.RegisterCodec(crpj.Name, crpj.NewServerCodec())
return sh
}

View File

@ -1,19 +1,11 @@
package server
import (
crpj "git.loafle.net/commons_go/rpc/protocol/json"
crr "git.loafle.net/commons_go/rpc/registry"
"git.loafle.net/commons_go/server"
)
func New(addr string, serverName string, rpcInvoker crr.RPCInvoker) server.Server {
rpcSH := newRPCServletHandler(rpcInvoker)
rpcSH.RegisterCodec(crpj.Name, crpj.NewServerCodec())
socketHandler := newSocketHandler(rpcSH)
sh := newServerHandler(addr, serverName, socketHandler)
s := server.New(sh)
func New(serverHandler ServerHandler) server.Server {
s := server.New(serverHandler)
return s
}

View File

@ -7,7 +7,7 @@ import (
"git.loafle.net/commons_go/server"
)
func newServerHandler(addr string, serverName string, socketHandler SocketHandler) ServerHandler {
func NewServerHandler(addr string, serverName string, socketHandler SocketHandler) ServerHandler {
sh := &ServerHandlers{
addr: addr,
}

View File

@ -12,7 +12,7 @@ import (
oopc "git.loafle.net/overflow/overflow_probe_container"
)
func newSocketHandler(rpcSH RPCServletHandler) SocketHandler {
func NewSocketHandler(rpcSH RPCServletHandler) SocketHandler {
rpcRWCSH := crsrs.New()
sh := &SocketHandlers{
@ -39,7 +39,7 @@ func (sh *SocketHandlers) Init(serverCTX server.ServerContext) error {
}
func (sh *SocketHandlers) Handshake(socketCTX server.SocketContext, conn net.Conn) (id string) {
return "discovery"
return "server"
}
func (sh *SocketHandlers) OnConnect(soc server.Socket) {