websocket增加消息类型常量

This commit is contained in:
John
2018-08-31 23:53:57 +08:00
parent 5c95f2388c
commit 051c9581ea
3 changed files with 27 additions and 5 deletions

View File

@ -204,8 +204,8 @@ func GetServer(name...interface{}) (*Server) {
nameToUriType : gtype.NewInt(),
gzipMimesMap : make(map[string]struct{}),
}
s.errorLogger.SetBacktraceSkip(1)
s.accessLogger.SetBacktraceSkip(1)
//s.errorLogger.SetBacktraceSkip(1)
//s.accessLogger.SetBacktraceSkip(1)
// 设置路由解析缓存上限使用LRU进行缓存淘汰
s.serveCache.SetCap(gSERVE_CACHE_LRU_SIZE)
s.hooksCache.SetCap(gHOOKS_CACHE_LRU_SIZE)

View File

@ -11,4 +11,26 @@ import "github.com/gorilla/websocket"
type WebSocket struct {
*websocket.Conn
}
}
const (
// TextMessage denotes a text data message. The text message payload is
// interpreted as UTF-8 encoded text data.
WS_MSG_TEXT = websocket.TextMessage
// BinaryMessage denotes a binary data message.
WS_MSG_BINARY = websocket.BinaryMessage
// CloseMessage denotes a close control message. The optional message
// payload contains a numeric code and text. Use the FormatCloseMessage
// function to format a close message payload.
WS_MSG_CLOSE = websocket.CloseMessage
// PingMessage denotes a ping control message. The optional message payload
// is UTF-8 encoded text.
WS_MSG_PING = websocket.PingMessage
// PongMessage denotes a pong control message. The optional message payload
// is UTF-8 encoded text.
WS_MSG_PONG = websocket.PongMessage
)

View File

@ -169,7 +169,7 @@ func (l *Logger) stdPrint(s string) {
func (l *Logger) errPrint(s string) {
// 记录调用回溯信息
if l.btEnabled.Val() {
backtrace := l.GetBacktrace(2)
backtrace := l.GetBacktrace(3)
if s[len(s) - 1] == byte('\n') {
s = s + backtrace + ln
} else {
@ -199,7 +199,7 @@ func (l *Logger) GetBacktrace(skip...int) string {
for i := 1; i < 10000; i++ {
if _, cfile, cline, ok := runtime.Caller(customSkip + i + l.btSkip.Val()); ok {
// 不打印出go源码路径
if !gregex.IsMatchString("^" + gfile.GoRootOfBuild(), cfile) {
if !gregex.IsMatchString("^" + gfile.GoRootOfBuild(), cfile) && !gregex.IsMatchString(`<autogenerated>`, cfile) {
backtrace += strconv.Itoa(index) + ".\t" + cfile + ":" + strconv.Itoa(cline) + ln
index++
}