Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
f7505d10
Commit
f7505d10
authored
Nov 19, 2016
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ws comperss feature
parent
b3e7c618
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
8 deletions
+20
-8
change_log.md
change_log.md
+8
-3
client.go
client.go
+4
-1
conn.go
conn.go
+3
-0
server.go
server.go
+2
-1
version.go
version.go
+3
-3
No files found.
change_log.md
View file @
f7505d10
...
...
@@ -11,11 +11,16 @@
## develop history ##
---
-
2016/11/19
> 1 add conn.go:(*gettyWSConn) setCompressType to add zip compress feature for ws connection
>
> 2 version: 0.6.2
-
2016/11/16
> 1 add zip/snappy compress for tcp
/ws
connection
> 1 add zip/snappy compress for tcp connection
>
> 2 version: 0.6.
0
1
> 2 version: 0.6.1
-
2016/11/02
> 1 add session.go:Session{ID(), LocalAddr(), RemoteAddr()}
>
...
...
client.go
View file @
f7505d10
...
...
@@ -128,6 +128,7 @@ func (this *Client) dialWS() *Session {
session
*
Session
)
dialer
.
EnableCompression
=
true
for
{
if
this
.
IsClosed
()
{
return
nil
...
...
@@ -161,6 +162,7 @@ func (this *Client) dialWSS() *Session {
session
*
Session
)
dialer
.
EnableCompression
=
true
certPem
,
err
=
ioutil
.
ReadFile
(
this
.
certFile
)
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"ioutil.ReadFile(certFile{%s}) = err{%#v}"
,
this
.
certFile
,
err
))
...
...
@@ -170,6 +172,7 @@ func (this *Client) dialWSS() *Session {
panic
(
"failed to parse root certificate"
)
}
// dialer.EnableCompression = true
dialer
.
TLSClientConfig
=
&
tls
.
Config
{
RootCAs
:
certPool
}
for
{
if
this
.
IsClosed
()
{
...
...
@@ -273,7 +276,7 @@ func (this *Client) RunEventLoop(newSession NewSessionCallback) {
if
maxTimes
<
times
{
times
=
maxTimes
}
time
.
Sleep
(
time
.
Duration
(
times
*
defaultInterval
))
time
.
Sleep
(
time
.
Duration
(
int64
(
times
)
*
defaultInterval
))
continue
}
times
=
0
...
...
conn.go
View file @
f7505d10
...
...
@@ -301,6 +301,7 @@ func newGettyWSConn(conn *websocket.Conn) *gettyWSConn {
peer
:
peerAddr
,
},
}
conn
.
EnableWriteCompression
(
false
)
conn
.
SetPingHandler
(
gettyWSConn
.
handlePing
)
conn
.
SetPongHandler
(
gettyWSConn
.
handlePong
)
...
...
@@ -314,6 +315,8 @@ func (this *gettyWSConn) setCompressType(t CompressType) {
this
.
conn
.
EnableWriteCompression
(
true
)
case
t
==
CompressSnappy
:
this
.
conn
.
EnableWriteCompression
(
true
)
default
:
this
.
conn
.
EnableWriteCompression
(
false
)
}
}
...
...
server.go
View file @
f7505d10
...
...
@@ -142,7 +142,8 @@ func newWSHandler(server *Server, newSession NewSessionCallback) *wsHandler {
upgrader
:
websocket
.
Upgrader
{
// in default, ReadBufferSize & WriteBufferSize is 4k
// HandshakeTimeout: server.HTTPTimeout,
CheckOrigin
:
func
(
_
*
http
.
Request
)
bool
{
return
true
},
// allow connections from any origin
CheckOrigin
:
func
(
_
*
http
.
Request
)
bool
{
return
true
},
// allow connections from any origin
EnableCompression
:
true
,
},
}
}
...
...
version.go
View file @
f7505d10
...
...
@@ -10,9 +10,9 @@
package
getty
const
(
Version
=
"0.6.
01
"
DATE
=
"2016/11/1
6
"
Version
=
"0.6.
2
"
DATE
=
"2016/11/1
9
"
GETTY_MAJOR
=
0
GETTY_MINOR
=
6
GETTY_BUILD
=
1
GETTY_BUILD
=
2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment