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
34ccf56d
Commit
34ccf56d
authored
Mar 17, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check parameters
parent
35056ac3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
client.go
client.go
+5
-2
server.go
server.go
+16
-0
No files found.
client.go
View file @
34ccf56d
...
...
@@ -113,8 +113,8 @@ func NewUDPClient(connNum int, connInterval time.Duration, serverAddr string) *C
// @connInterval is reconnect sleep interval when getty fails to connect the server.
// @serverAddr is server address. its prefix should be "ws://".
func
NewWSClient
(
connNum
int
,
connInterval
time
.
Duration
,
serverAddr
string
)
*
Client
{
if
connNum
<=
0
{
connNum
=
1
if
connNum
<=
0
||
serverAddr
==
""
{
panic
(
fmt
.
Sprintf
(
"@connNum:%d, @serverAddr:%s"
,
connNum
,
serverAddr
))
}
if
connInterval
<
defaultInterval
{
connInterval
=
defaultInterval
...
...
@@ -142,6 +142,9 @@ func NewWSClient(connNum int, connInterval time.Duration, serverAddr string) *Cl
// @privateKey is client private key(contains its public key). it can be empty.
// @caCert is the root certificate file to verify the legitimacy of server
func
NewWSSClient
(
connNum
int
,
connInterval
time
.
Duration
,
serverAddr
string
,
cert
string
)
*
Client
{
if
connNum
<=
0
||
serverAddr
==
""
||
cert
==
""
{
panic
(
fmt
.
Sprintf
(
"@connNum:%d, @serverAddr:%s, @cert:%s"
,
connNum
,
serverAddr
,
cert
))
}
if
connNum
<=
0
{
connNum
=
1
...
...
server.go
View file @
34ccf56d
...
...
@@ -57,6 +57,10 @@ type Server struct {
// NewTCServer builds a tcp server.
// @addr server listen address.
func
NewTCPServer
(
addr
string
)
*
Server
{
if
addr
==
""
{
panic
(
fmt
.
Sprintf
(
"@addr:%s"
,
addr
))
}
return
&
Server
{
endPointType
:
TCP_SERVER
,
done
:
make
(
chan
gxsync
.
Empty
),
...
...
@@ -67,6 +71,10 @@ func NewTCPServer(addr string) *Server {
// NewUDPServer builds a unconnected udp server.
// @addr server listen address.
func
NewUDPPServer
(
addr
string
)
*
Server
{
if
addr
==
""
{
panic
(
fmt
.
Sprintf
(
"@addr:%s"
,
addr
))
}
return
&
Server
{
endPointType
:
UDP_SERVER
,
done
:
make
(
chan
gxsync
.
Empty
),
...
...
@@ -78,6 +86,10 @@ func NewUDPPServer(addr string) *Server {
// @addr server listen address.
// @path: websocket request url path
func
NewWSServer
(
addr
string
,
path
string
)
*
Server
{
if
addr
==
""
{
panic
(
fmt
.
Sprintf
(
"@addr:%s"
,
addr
))
}
return
&
Server
{
endPointType
:
WS_SERVER
,
done
:
make
(
chan
gxsync
.
Empty
),
...
...
@@ -93,6 +105,10 @@ func NewWSServer(addr string, path string) *Server {
// @privateKey: server private key(contains its public key)
// @caCert: root certificate file. to verify the legitimacy of client. it can be nil.
func
NewWSSServer
(
addr
,
path
,
cert
,
privateKey
,
caCert
string
)
*
Server
{
if
addr
==
""
||
cert
==
""
||
privateKey
==
""
||
caCert
==
""
{
panic
(
fmt
.
Sprintf
(
"@addr:%s, @cert:%s, @privateKey:%s, @caCert:%s"
,
addr
,
cert
,
privateKey
,
caCert
))
}
return
&
Server
{
endPointType
:
WSS_SERVER
,
done
:
make
(
chan
gxsync
.
Empty
),
...
...
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