Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
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
a4ce4402
Commit
a4ce4402
authored
Jan 26, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete gocolor, use gxlog instead
parent
066a35c5
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
41 additions
and
43 deletions
+41
-43
config.go
echo/tcp-echo/client/app/config.go
+1
-2
main.go
echo/tcp-echo/client/app/main.go
+3
-3
config.go
echo/tcp-echo/server/app/config.go
+1
-2
server.go
echo/tcp-echo/server/app/server.go
+2
-2
config.go
echo/ws-echo/client/app/config.go
+2
-2
main.go
echo/ws-echo/client/app/main.go
+3
-3
main.js
echo/ws-echo/js-client/main.js
+8
-8
config.go
echo/ws-echo/server/app/config.go
+2
-2
server.go
echo/ws-echo/server/app/server.go
+2
-2
config.go
echo/wss-echo/client/app/config.go
+2
-2
main.go
echo/wss-echo/client/app/main.go
+3
-3
main.js
echo/wss-echo/js-client/main.js
+8
-8
config.go
echo/wss-echo/server/app/config.go
+2
-2
server.go
echo/wss-echo/server/app/server.go
+2
-2
No files found.
echo/tcp-echo/client/app/config.go
View file @
a4ce4402
...
@@ -17,7 +17,6 @@ import (
...
@@ -17,7 +17,6 @@ import (
)
)
import
(
import
(
// "github.com/AlexStocks/gocolor"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
config
"github.com/koding/multiconfig"
config
"github.com/koding/multiconfig"
)
)
...
@@ -139,7 +138,7 @@ func initConf() {
...
@@ -139,7 +138,7 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
return
return
}
}
// g
ocolor
.Info("config{%#v}\n", conf)
// g
xlog
.Info("config{%#v}\n", conf)
// log
// log
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
...
...
echo/tcp-echo/client/app/main.go
View file @
a4ce4402
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
import
(
import
(
"github.com/AlexStocks/getty"
"github.com/AlexStocks/getty"
"github.com/AlexStocks/go
color
"
"github.com/AlexStocks/go
ext/log
"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/time"
"github.com/AlexStocks/goext/time"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
...
@@ -49,7 +49,7 @@ func main() {
...
@@ -49,7 +49,7 @@ func main() {
initProfiling
()
initProfiling
()
initClient
()
initClient
()
g
ocolor
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
g
xlog
.
C
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
log
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
log
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
go
test
()
go
test
()
...
@@ -182,5 +182,5 @@ func test() {
...
@@ -182,5 +182,5 @@ func test() {
}
}
cost
=
counter
.
Count
()
cost
=
counter
.
Count
()
log
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
log
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
g
ocolor
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
g
xlog
.
C
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
}
}
echo/tcp-echo/server/app/config.go
View file @
a4ce4402
...
@@ -17,7 +17,6 @@ import (
...
@@ -17,7 +17,6 @@ import (
)
)
import
(
import
(
// "github.com/AlexStocks/gocolor"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
config
"github.com/koding/multiconfig"
config
"github.com/koding/multiconfig"
)
)
...
@@ -114,7 +113,7 @@ func initConf() {
...
@@ -114,7 +113,7 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
return
return
}
}
// g
ocolor.
Info("config{%#v}\n", conf)
// g
xlog.C
Info("config{%#v}\n", conf)
// log
// log
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
...
...
echo/tcp-echo/server/app/server.go
View file @
a4ce4402
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
import
(
import
(
"github.com/AlexStocks/getty"
"github.com/AlexStocks/getty"
"github.com/AlexStocks/go
color
"
"github.com/AlexStocks/go
ext/log
"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/net"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
)
)
...
@@ -53,7 +53,7 @@ func main() {
...
@@ -53,7 +53,7 @@ func main() {
initProfiling
()
initProfiling
()
initServer
()
initServer
()
g
ocolor
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s
\n
"
,
g
xlog
.
C
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s
\n
"
,
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
)
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
)
log
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s
\n
"
,
log
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s
\n
"
,
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
)
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
)
...
...
echo/ws-echo/client/app/config.go
View file @
a4ce4402
...
@@ -17,7 +17,7 @@ import (
...
@@ -17,7 +17,7 @@ import (
)
)
import
(
import
(
// "github.com/AlexStocks/go
color
"
// "github.com/AlexStocks/go
ext/log
"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
config
"github.com/koding/multiconfig"
config
"github.com/koding/multiconfig"
)
)
...
@@ -140,7 +140,7 @@ func initConf() {
...
@@ -140,7 +140,7 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
return
return
}
}
// g
ocolor.
Info("config{%#v}\n", conf)
// g
xlog.C
Info("config{%#v}\n", conf)
// log
// log
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
...
...
echo/ws-echo/client/app/main.go
View file @
a4ce4402
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
import
(
import
(
"github.com/AlexStocks/getty"
"github.com/AlexStocks/getty"
"github.com/AlexStocks/go
color
"
"github.com/AlexStocks/go
ext/log
"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/time"
"github.com/AlexStocks/goext/time"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
...
@@ -50,7 +50,7 @@ func main() {
...
@@ -50,7 +50,7 @@ func main() {
initProfiling
()
initProfiling
()
initClient
()
initClient
()
g
ocolor
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
g
xlog
.
C
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
log
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
log
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
go
test
()
go
test
()
...
@@ -191,5 +191,5 @@ func test() {
...
@@ -191,5 +191,5 @@ func test() {
}
}
cost
=
counter
.
Count
()
cost
=
counter
.
Count
()
log
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
log
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
g
ocolor
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
g
xlog
.
C
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
}
}
echo/ws-echo/js-client/main.js
View file @
a4ce4402
...
@@ -40,7 +40,7 @@ $(function() {
...
@@ -40,7 +40,7 @@ $(function() {
var
$chatPage
=
$
(
'.chat.page'
);
// The chatroom page
var
$chatPage
=
$
(
'.chat.page'
);
// The chatroom page
// var socket = new WebSocket('ws://192.168.35.1:10000/echo');
// var socket = new WebSocket('ws://192.168.35.1:10000/echo');
var
socket
=
new
WebSocket
(
'ws://'
+
serverAddress
+
'/echo'
)
var
socket
=
new
WebSocket
(
'ws://'
+
serverAddress
+
'/echo'
)
;
// // Setting binaryType to accept received binary as either 'blob' or 'arraybuffer'. In default it is 'blob'.
// // Setting binaryType to accept received binary as either 'blob' or 'arraybuffer'. In default it is 'blob'.
// socket.binaryType = 'arraybuffer';
// socket.binaryType = 'arraybuffer';
// socket.binaryType = ''
// socket.binaryType = ''
...
@@ -61,7 +61,7 @@ $(function() {
...
@@ -61,7 +61,7 @@ $(function() {
var
tmp
=
new
Uint8Array
(
header
.
byteLength
+
1
+
msg
.
length
);
var
tmp
=
new
Uint8Array
(
header
.
byteLength
+
1
+
msg
.
length
);
tmp
.
set
(
new
Uint8Array
(
header
),
0
);
tmp
.
set
(
new
Uint8Array
(
header
),
0
);
tmp
[
header
.
byteLength
]
=
msg
.
length
tmp
[
header
.
byteLength
]
=
msg
.
length
;
var
ma
=
new
TextEncoder
(
"utf-8"
).
encode
(
msg
);
var
ma
=
new
TextEncoder
(
"utf-8"
).
encode
(
msg
);
tmp
.
set
(
ma
,
header
.
byteLength
+
1
);
tmp
.
set
(
ma
,
header
.
byteLength
+
1
);
...
@@ -136,12 +136,12 @@ $(function() {
...
@@ -136,12 +136,12 @@ $(function() {
addMessageElement
(
$el
,
options
);
addMessageElement
(
$el
,
options
);
}
}
var
imgReg
=
/:img
\s
+
(\S
+
)
/
var
imgReg
=
/:img
\s
+
(\S
+
)
/
;
// Adds the visual chat message to the message list
// Adds the visual chat message to the message list
function
addChatMessage
(
data
,
options
)
{
function
addChatMessage
(
data
,
options
)
{
// Don't fade the message in if there is an 'X was typing'
// Don't fade the message in if there is an 'X was typing'
options
=
options
||
{};
options
=
options
||
{};
var
regRes
=
imgReg
.
exec
(
data
.
Message
)
var
regRes
=
imgReg
.
exec
(
data
.
Message
)
;
if
(
regRes
!=
null
)
{
if
(
regRes
!=
null
)
{
var
$messageBodyDiv
=
$
(
'<img src="'
+
regRes
[
1
]
+
'">'
);
var
$messageBodyDiv
=
$
(
'<img src="'
+
regRes
[
1
]
+
'">'
);
}
else
{
}
else
{
...
@@ -209,7 +209,7 @@ $(function() {
...
@@ -209,7 +209,7 @@ $(function() {
socket
.
onopen
=
function
()
{
socket
.
onopen
=
function
()
{
console
.
log
(
'websocket extensions:'
+
socket
.
extensions
);
console
.
log
(
'websocket extensions:'
+
socket
.
extensions
);
}
}
;
// Socket events
// Socket events
socket
.
onmessage
=
function
(
e
)
{
socket
.
onmessage
=
function
(
e
)
{
// e.data is blob
// e.data is blob
...
@@ -220,15 +220,15 @@ $(function() {
...
@@ -220,15 +220,15 @@ $(function() {
unmarshalEchoPkg
(
dv
.
buffer
)
unmarshalEchoPkg
(
dv
.
buffer
)
};
};
fileReader
.
readAsArrayBuffer
(
e
.
data
);
// 此处读取blob
fileReader
.
readAsArrayBuffer
(
e
.
data
);
// 此处读取blob
}
}
;
socket
.
onclose
=
function
(
e
)
{
socket
.
onclose
=
function
(
e
)
{
// console.log("socket.onclose" + e.reason)
// console.log("socket.onclose" + e.reason)
disconnect
()
disconnect
()
;
addChatMessage
({
addChatMessage
({
Message
:
e
.
reason
+
'!!SYSTEM-WS-Close, connection closed'
Message
:
e
.
reason
+
'!!SYSTEM-WS-Close, connection closed'
});
});
}
}
;
socket
.
onerror
=
function
()
{
socket
.
onerror
=
function
()
{
addChatMessage
({
addChatMessage
({
...
...
echo/ws-echo/server/app/config.go
View file @
a4ce4402
...
@@ -17,7 +17,7 @@ import (
...
@@ -17,7 +17,7 @@ import (
)
)
import
(
import
(
// "github.com/AlexStocks/go
color
"
// "github.com/AlexStocks/go
ext/log
"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
config
"github.com/koding/multiconfig"
config
"github.com/koding/multiconfig"
)
)
...
@@ -126,7 +126,7 @@ func initConf() {
...
@@ -126,7 +126,7 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
return
return
}
}
// g
ocolor.
Info("config{%#v}\n", conf)
// g
xlog.C
Info("config{%#v}\n", conf)
// log
// log
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
...
...
echo/ws-echo/server/app/server.go
View file @
a4ce4402
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
import
(
import
(
"github.com/AlexStocks/getty"
"github.com/AlexStocks/getty"
"github.com/AlexStocks/go
color
"
"github.com/AlexStocks/go
ext/log
"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/net"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
)
)
...
@@ -54,7 +54,7 @@ func main() {
...
@@ -54,7 +54,7 @@ func main() {
initProfiling
()
initProfiling
()
initServer
()
initServer
()
g
ocolor
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s:%s
\n
"
,
g
xlog
.
C
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s:%s
\n
"
,
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
,
conf
.
Paths
)
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
,
conf
.
Paths
)
log
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s:%s
\n
"
,
log
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s:%s
\n
"
,
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
,
conf
.
Paths
)
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
,
conf
.
Paths
)
...
...
echo/wss-echo/client/app/config.go
View file @
a4ce4402
...
@@ -17,7 +17,7 @@ import (
...
@@ -17,7 +17,7 @@ import (
)
)
import
(
import
(
// "github.com/AlexStocks/go
color
"
// "github.com/AlexStocks/go
ext/log
"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
config
"github.com/koding/multiconfig"
config
"github.com/koding/multiconfig"
)
)
...
@@ -144,7 +144,7 @@ func initConf() {
...
@@ -144,7 +144,7 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
return
return
}
}
// g
ocolor.
Info("config{%#v}\n", conf)
// g
xlog.C
Info("config{%#v}\n", conf)
// log
// log
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
...
...
echo/wss-echo/client/app/main.go
View file @
a4ce4402
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
import
(
import
(
"github.com/AlexStocks/getty"
"github.com/AlexStocks/getty"
"github.com/AlexStocks/go
color
"
"github.com/AlexStocks/go
ext/log
"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/time"
"github.com/AlexStocks/goext/time"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
...
@@ -50,7 +50,7 @@ func main() {
...
@@ -50,7 +50,7 @@ func main() {
initProfiling
()
initProfiling
()
initClient
()
initClient
()
g
ocolor
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
g
xlog
.
C
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
log
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
log
.
Info
(
"%s starts successfull! its version=%s
\n
"
,
conf
.
AppName
,
Version
)
go
test
()
go
test
()
...
@@ -200,5 +200,5 @@ func test() {
...
@@ -200,5 +200,5 @@ func test() {
}
}
cost
=
counter
.
Count
()
cost
=
counter
.
Count
()
log
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
log
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
g
ocolor
.
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
g
xlog
.
C
Info
(
"after loop %d times, echo cost %d ms"
,
conf
.
EchoTimes
,
cost
/
1e6
)
}
}
echo/wss-echo/js-client/main.js
View file @
a4ce4402
...
@@ -48,7 +48,7 @@ $(function() {
...
@@ -48,7 +48,7 @@ $(function() {
// http://stackoverflow.com/questions/7580508/getting-chrome-to-accept-self-signed-localhost-certificate#comment33762412_15076602
// http://stackoverflow.com/questions/7580508/getting-chrome-to-accept-self-signed-localhost-certificate#comment33762412_15076602
// chrome://flags/#allow-insecure-localhost
// chrome://flags/#allow-insecure-localhost
var
socket
=
new
WebSocket
(
'wss://'
+
serverAddress
+
'/echo'
)
var
socket
=
new
WebSocket
(
'wss://'
+
serverAddress
+
'/echo'
)
;
// // Setting binaryType to accept received binary as either 'blob' or 'arraybuffer'. In default it is 'blob'.
// // Setting binaryType to accept received binary as either 'blob' or 'arraybuffer'. In default it is 'blob'.
// socket.binaryType = 'arraybuffer';
// socket.binaryType = 'arraybuffer';
// socket.binaryType = ''
// socket.binaryType = ''
...
@@ -69,7 +69,7 @@ $(function() {
...
@@ -69,7 +69,7 @@ $(function() {
var
tmp
=
new
Uint8Array
(
header
.
byteLength
+
1
+
msg
.
length
);
var
tmp
=
new
Uint8Array
(
header
.
byteLength
+
1
+
msg
.
length
);
tmp
.
set
(
new
Uint8Array
(
header
),
0
);
tmp
.
set
(
new
Uint8Array
(
header
),
0
);
tmp
[
header
.
byteLength
]
=
msg
.
length
tmp
[
header
.
byteLength
]
=
msg
.
length
;
var
ma
=
new
TextEncoder
(
"utf-8"
).
encode
(
msg
);
var
ma
=
new
TextEncoder
(
"utf-8"
).
encode
(
msg
);
tmp
.
set
(
ma
,
header
.
byteLength
+
1
);
tmp
.
set
(
ma
,
header
.
byteLength
+
1
);
...
@@ -144,12 +144,12 @@ $(function() {
...
@@ -144,12 +144,12 @@ $(function() {
addMessageElement
(
$el
,
options
);
addMessageElement
(
$el
,
options
);
}
}
var
imgReg
=
/:img
\s
+
(\S
+
)
/
var
imgReg
=
/:img
\s
+
(\S
+
)
/
;
// Adds the visual chat message to the message list
// Adds the visual chat message to the message list
function
addChatMessage
(
data
,
options
)
{
function
addChatMessage
(
data
,
options
)
{
// Don't fade the message in if there is an 'X was typing'
// Don't fade the message in if there is an 'X was typing'
options
=
options
||
{};
options
=
options
||
{};
var
regRes
=
imgReg
.
exec
(
data
.
Message
)
var
regRes
=
imgReg
.
exec
(
data
.
Message
)
;
if
(
regRes
!=
null
)
{
if
(
regRes
!=
null
)
{
var
$messageBodyDiv
=
$
(
'<img src="'
+
regRes
[
1
]
+
'">'
);
var
$messageBodyDiv
=
$
(
'<img src="'
+
regRes
[
1
]
+
'">'
);
}
else
{
}
else
{
...
@@ -217,7 +217,7 @@ $(function() {
...
@@ -217,7 +217,7 @@ $(function() {
socket
.
onopen
=
function
()
{
socket
.
onopen
=
function
()
{
console
.
log
(
'websocket extensions:'
+
socket
.
extensions
);
console
.
log
(
'websocket extensions:'
+
socket
.
extensions
);
}
}
;
// Socket events
// Socket events
socket
.
onmessage
=
function
(
e
)
{
socket
.
onmessage
=
function
(
e
)
{
// e.data is blob
// e.data is blob
...
@@ -228,15 +228,15 @@ $(function() {
...
@@ -228,15 +228,15 @@ $(function() {
unmarshalEchoPkg
(
dv
.
buffer
)
unmarshalEchoPkg
(
dv
.
buffer
)
};
};
fileReader
.
readAsArrayBuffer
(
e
.
data
);
// 此处读取blob
fileReader
.
readAsArrayBuffer
(
e
.
data
);
// 此处读取blob
}
}
;
socket
.
onclose
=
function
(
e
)
{
socket
.
onclose
=
function
(
e
)
{
// console.log("socket.onclose" + e.reason)
// console.log("socket.onclose" + e.reason)
disconnect
()
disconnect
()
;
addChatMessage
({
addChatMessage
({
Message
:
e
.
reason
+
'!!SYSTEM-WS-Close, connection closed'
Message
:
e
.
reason
+
'!!SYSTEM-WS-Close, connection closed'
});
});
}
}
;
socket
.
onerror
=
function
()
{
socket
.
onerror
=
function
()
{
addChatMessage
({
addChatMessage
({
...
...
echo/wss-echo/server/app/config.go
View file @
a4ce4402
...
@@ -17,7 +17,7 @@ import (
...
@@ -17,7 +17,7 @@ import (
)
)
import
(
import
(
// "github.com/AlexStocks/go
color
"
// "github.com/AlexStocks/go
ext/log
"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
config
"github.com/koding/multiconfig"
config
"github.com/koding/multiconfig"
)
)
...
@@ -132,7 +132,7 @@ func initConf() {
...
@@ -132,7 +132,7 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
panic
(
fmt
.
Sprintf
(
"time.ParseDuration(WaitTimeout{%#v}) = error{%v}"
,
conf
.
GettySessionParam
.
WaitTimeout
,
err
))
return
return
}
}
// g
ocolor.
Info("config{%#v}\n", conf)
// g
xlog.C
Info("config{%#v}\n", conf)
// log
// log
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
...
...
echo/wss-echo/server/app/server.go
View file @
a4ce4402
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
import
(
import
(
"github.com/AlexStocks/getty"
"github.com/AlexStocks/getty"
"github.com/AlexStocks/go
color
"
"github.com/AlexStocks/go
ext/log
"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/net"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
)
)
...
@@ -54,7 +54,7 @@ func main() {
...
@@ -54,7 +54,7 @@ func main() {
initProfiling
()
initProfiling
()
initServer
()
initServer
()
g
ocolor
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s:%s
\n
"
,
g
xlog
.
C
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s:%s
\n
"
,
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
,
conf
.
Paths
)
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
,
conf
.
Paths
)
log
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s:%s
\n
"
,
log
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s:%s
\n
"
,
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
,
conf
.
Paths
)
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
,
conf
.
Paths
)
...
...
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