From 6614bd5489f5ea06b41ae64b57df47a55c579b61 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 5 Dec 2017 14:40:31 +0900 Subject: [PATCH] ing --- server/rpc_servlet_handlers.go | 4 +++- server/server.go | 12 ++---------- server/server_handlers.go | 2 +- server/socket_handlers.go | 4 ++-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/server/rpc_servlet_handlers.go b/server/rpc_servlet_handlers.go index 429abaf..7b9ed3c 100644 --- a/server/rpc_servlet_handlers.go +++ b/server/rpc_servlet_handlers.go @@ -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 } diff --git a/server/server.go b/server/server.go index b81f267..b382f7f 100644 --- a/server/server.go +++ b/server/server.go @@ -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 } diff --git a/server/server_handlers.go b/server/server_handlers.go index 0727b14..c20ecdb 100644 --- a/server/server_handlers.go +++ b/server/server_handlers.go @@ -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, } diff --git a/server/socket_handlers.go b/server/socket_handlers.go index 23be9fd..cf9e51a 100644 --- a/server/socket_handlers.go +++ b/server/socket_handlers.go @@ -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) {