From 20a63b3de6efdc0942bfb4be21ddc64e2b76f59d Mon Sep 17 00:00:00 2001 From: crusader Date: Sun, 1 Jul 2018 01:52:05 +0900 Subject: [PATCH] ing --- socket/readwrite-handler.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/socket/readwrite-handler.go b/socket/readwrite-handler.go index 275d525..45879b7 100644 --- a/socket/readwrite-handler.go +++ b/socket/readwrite-handler.go @@ -16,6 +16,7 @@ type ReadWriteHandler interface { IsEnableCompression() bool GetCompressionLevel() int + GetCompressionThreshold() int } type ReadWriteHandlers struct { @@ -25,8 +26,9 @@ type ReadWriteHandlers struct { PingTimeout time.Duration `json:"pingTimeout,omitempty"` PingPeriod time.Duration `json:"pingPeriod,omitempty"` - EnableCompression bool `json:"enableCompression,omitempty"` - CompressionLevel int `json:"compressionLevel,omitempty"` + EnableCompression bool `json:"enableCompression,omitempty"` + CompressionLevel int `json:"compressionLevel,omitempty"` + CompressionThreshold int `json:"compressionThreshold,omitempty"` validated atomic.Value } @@ -47,16 +49,20 @@ func (rwh *ReadWriteHandlers) IsEnableCompression() bool { func (rwh *ReadWriteHandlers) GetCompressionLevel() int { return rwh.CompressionLevel } +func (rwh *ReadWriteHandlers) GetCompressionThreshold() int { + return rwh.CompressionThreshold +} func (rwh *ReadWriteHandlers) Clone() *ReadWriteHandlers { return &ReadWriteHandlers{ - ReadWriteHandlers: *rwh.ReadWriteHandlers.Clone(), - PongTimeout: rwh.PongTimeout, - PingTimeout: rwh.PingTimeout, - PingPeriod: rwh.PingPeriod, - EnableCompression: rwh.EnableCompression, - CompressionLevel: rwh.CompressionLevel, - validated: rwh.validated, + ReadWriteHandlers: *rwh.ReadWriteHandlers.Clone(), + PongTimeout: rwh.PongTimeout, + PingTimeout: rwh.PingTimeout, + PingPeriod: rwh.PingPeriod, + EnableCompression: rwh.EnableCompression, + CompressionLevel: rwh.CompressionLevel, + CompressionThreshold: rwh.CompressionThreshold, + validated: rwh.validated, } } @@ -93,5 +99,9 @@ func (rwh *ReadWriteHandlers) Validate() error { } } + if 0 > rwh.CompressionThreshold { + rwh.CompressionThreshold = server.DefaultCompressionThreshold + } + return nil }