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
f108db1d
Commit
f108db1d
authored
Nov 21, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: delete Empty
parent
6a7f8a34
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
15 deletions
+12
-15
client.go
client.go
+5
-6
listener.go
rpc/listener.go
+2
-2
server.go
server.go
+2
-3
session.go
session.go
+3
-4
No files found.
client.go
View file @
f108db1d
...
...
@@ -23,7 +23,6 @@ import (
import
(
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/sync"
log
"github.com/AlexStocks/log4go"
"github.com/gorilla/websocket"
jerrors
"github.com/juju/errors"
...
...
@@ -52,10 +51,10 @@ type client struct {
endPointType
EndPointType
newSession
NewSessionCallback
ssMap
map
[
Session
]
gxsync
.
Empty
ssMap
map
[
Session
]
struct
{}
sync
.
Once
done
chan
gxsync
.
Empty
done
chan
struct
{}
wg
sync
.
WaitGroup
}
...
...
@@ -68,7 +67,7 @@ func (c *client) init(opts ...ClientOption) {
func
newClient
(
t
EndPointType
,
opts
...
ClientOption
)
*
client
{
c
:=
&
client
{
endPointType
:
t
,
done
:
make
(
chan
gxsync
.
Empty
),
done
:
make
(
chan
struct
{}
),
}
c
.
init
(
opts
...
)
...
...
@@ -77,7 +76,7 @@ func newClient(t EndPointType, opts ...ClientOption) *client {
panic
(
fmt
.
Sprintf
(
"client type:%s, @connNum:%d, @serverAddr:%s"
,
t
,
c
.
number
,
c
.
addr
))
}
c
.
ssMap
=
make
(
map
[
Session
]
gxsync
.
Empty
,
c
.
number
)
c
.
ssMap
=
make
(
map
[
Session
]
struct
{}
,
c
.
number
)
return
c
}
...
...
@@ -362,7 +361,7 @@ func (c *client) connect() {
// ss.RunEventLoop()
ss
.
(
*
session
)
.
run
()
c
.
Lock
()
c
.
ssMap
[
ss
]
=
gxsync
.
Empty
{}
c
.
ssMap
[
ss
]
=
struct
{}
{}
c
.
Unlock
()
ss
.
SetAttribute
(
sessionClientKey
,
c
)
break
...
...
rpc/listener.go
View file @
f108db1d
...
...
@@ -14,7 +14,7 @@ import (
)
var
(
errTooManySessions
=
jerrors
.
New
(
"too many
echo
sessions"
)
errTooManySessions
=
jerrors
.
New
(
"too many sessions"
)
)
type
rpcSession
struct
{
...
...
@@ -44,7 +44,7 @@ func NewRpcServerHandler(maxSessionNum int, sessionTimeout time.Duration) *RpcSe
func
(
h
*
RpcServerHandler
)
OnOpen
(
session
getty
.
Session
)
error
{
var
err
error
h
.
rwlock
.
RLock
()
if
h
.
maxSessionNum
<
len
(
h
.
sessionMap
)
{
if
h
.
maxSessionNum
<
=
len
(
h
.
sessionMap
)
{
err
=
errTooManySessions
}
h
.
rwlock
.
RUnlock
()
...
...
server.go
View file @
f108db1d
...
...
@@ -23,7 +23,6 @@ import (
import
(
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/sync"
"github.com/AlexStocks/goext/time"
log
"github.com/AlexStocks/log4go"
"github.com/gorilla/websocket"
...
...
@@ -46,7 +45,7 @@ type server struct {
server
*
http
.
Server
// for ws or wss server
sync
.
Once
done
chan
gxsync
.
Empty
done
chan
struct
{}
wg
sync
.
WaitGroup
}
...
...
@@ -59,7 +58,7 @@ func (s *server) init(opts ...ServerOption) {
func
newServer
(
t
EndPointType
,
opts
...
ServerOption
)
*
server
{
s
:=
&
server
{
endPointType
:
t
,
done
:
make
(
chan
gxsync
.
Empty
),
done
:
make
(
chan
struct
{}
),
}
s
.
init
(
opts
...
)
...
...
session.go
View file @
f108db1d
...
...
@@ -27,7 +27,6 @@ import (
import
(
"github.com/AlexStocks/goext/context"
"github.com/AlexStocks/goext/sync"
"github.com/AlexStocks/goext/time"
)
...
...
@@ -68,7 +67,7 @@ type session struct {
writer
Writer
listener
EventListener
once
sync
.
Once
done
chan
gxsync
.
Empty
done
chan
struct
{}
// errFlag bool
period
time
.
Duration
...
...
@@ -89,7 +88,7 @@ func newSession(endPoint EndPoint, conn Connection) *session {
endPoint
:
endPoint
,
maxMsgLen
:
maxReadBufLen
,
Connection
:
conn
,
done
:
make
(
chan
gxsync
.
Empty
),
done
:
make
(
chan
struct
{}
),
period
:
period
,
wait
:
pendingDuration
,
attrs
:
gxcontext
.
NewValuesContext
(
nil
),
...
...
@@ -129,7 +128,7 @@ func newWSSession(conn *websocket.Conn, endPoint EndPoint) Session {
func
(
s
*
session
)
Reset
()
{
s
.
name
=
defaultSessionName
s
.
once
=
sync
.
Once
{}
s
.
done
=
make
(
chan
gxsync
.
Empty
)
s
.
done
=
make
(
chan
struct
{}
)
// s.errFlag = false
s
.
period
=
period
s
.
wait
=
pendingDuration
...
...
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