1
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
r "math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -284,3 +285,13 @@ func GenFullUrl() (fullUrl string) {
|
|||||||
//fmt.Printf("Create websocket connect failCount:%d", retVal.UserCount)
|
//fmt.Printf("Create websocket connect failCount:%d", retVal.UserCount)
|
||||||
return fullUrl
|
return fullUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//生成随机字符串
|
||||||
|
func RandString() string {
|
||||||
|
bytes := make([]byte, 16)
|
||||||
|
for i := 0; i < 16; i++ {
|
||||||
|
b := r.Intn(26) + 65
|
||||||
|
bytes[i] = byte(b)
|
||||||
|
}
|
||||||
|
return string(bytes)
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,8 +48,12 @@ func Run(w http.ResponseWriter, r *http.Request) {
|
|||||||
//设置读取消息大小上线
|
//设置读取消息大小上线
|
||||||
conn.SetReadLimit(maxMessageSize)
|
conn.SetReadLimit(maxMessageSize)
|
||||||
|
|
||||||
//clientID := r.FormValue("clientId")
|
clientID := ""
|
||||||
clientID := r.Header.Get("Clientid")
|
if temp := r.Header.Get("Clientid"); len(temp) == 0 {
|
||||||
|
clientID = RandString()
|
||||||
|
} else {
|
||||||
|
clientID = temp
|
||||||
|
}
|
||||||
globals.SugarLogger.Debugf("Run clientID=%s", clientID)
|
globals.SugarLogger.Debugf("Run clientID=%s", clientID)
|
||||||
clientSocket := NewClient(clientID, conn)
|
clientSocket := NewClient(clientID, conn)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user