From e2ef11e395775afba410f39249208fc3cb9218de Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 31 Aug 2017 19:33:40 +0900 Subject: [PATCH] ing --- socket.go | 2 +- socket_handler.go | 2 +- socket_handlers.go | 32 ++++++++++++++++---------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/socket.go b/socket.go index 26f9db9..1f4c57d 100644 --- a/socket.go +++ b/socket.go @@ -94,7 +94,7 @@ func (soc *socket) onDisconnected() { } func (soc *socket) onMessage(messageType int, r io.Reader) { - result := soc.sh.GetProtocolHandler().OnMessage(soc, messageType, r) + result := soc.sh.GetProtocol().OnMessage(soc, messageType, r) if nil == result { return } diff --git a/socket_handler.go b/socket_handler.go index 1761974..4e23ba5 100644 --- a/socket_handler.go +++ b/socket_handler.go @@ -11,7 +11,7 @@ type SocketHandler interface { GetPingTimeout() time.Duration GetPingPeriod() time.Duration IsBinaryMessage() bool - GetProtocolHandler() ProtocolHandler + GetProtocol() ProtocolHandler Validate() } diff --git a/socket_handlers.go b/socket_handlers.go index 86ee9fe..46658db 100644 --- a/socket_handlers.go +++ b/socket_handlers.go @@ -24,7 +24,7 @@ const ( type SocketHandlers struct { onDisconnected func(soc Socket) - Handler ProtocolHandler + Protocol ProtocolHandler MaxMessageSize int64 WriteTimeout time.Duration @@ -57,34 +57,34 @@ func (sh *SocketHandlers) IsBinaryMessage() bool { return sh.BinaryMessage } -func (sh *SocketHandlers) GetProtocolHandler() ProtocolHandler { - return sh.Handler +func (sh *SocketHandlers) GetProtocol() ProtocolHandler { + return sh.Protocol } // Validate validates the configuration -func (o *SocketHandlers) Validate() { - if nil == o.Handler { - log.Fatalf("Message Handler must specified.\n") +func (sh *SocketHandlers) Validate() { + if nil == sh.Protocol { + log.Fatalln("Protocol must be specified.") } - if o.WriteTimeout < 0 { - o.WriteTimeout = DefaultWriteTimeout + if sh.WriteTimeout < 0 { + sh.WriteTimeout = DefaultWriteTimeout } - if o.ReadTimeout < 0 { - o.ReadTimeout = DefaultReadTimeout + if sh.ReadTimeout < 0 { + sh.ReadTimeout = DefaultReadTimeout } - if o.PongTimeout < 0 { - o.PongTimeout = DefaultPongTimeout + if sh.PongTimeout < 0 { + sh.PongTimeout = DefaultPongTimeout } - if o.PingPeriod <= 0 { - o.PingPeriod = DefaultPingPeriod + if sh.PingPeriod <= 0 { + sh.PingPeriod = DefaultPingPeriod } - if o.MaxMessageSize <= 0 { - o.MaxMessageSize = DefaultMaxMessageSize + if sh.MaxMessageSize <= 0 { + sh.MaxMessageSize = DefaultMaxMessageSize } }