Commit eca82664 authored by haoyanbin's avatar haoyanbin

Conf

parent d3c3d90e
......@@ -5,7 +5,7 @@ import (
"github.com/streadway/amqp"
)
var mqUrl = "amqp://admin:admin@127.0.0.1:5672/"
var mqUrl = "amqp://admin:admin@172.17.36.64:5672/"
// 除了simple 模式外、其他的模式都是由 队列 交换机 key 不同组合实现的
type RabbitMQ struct {
......
......@@ -26,7 +26,7 @@ const (
//
closeWait = 60 * 30 * time.Second
// time for auto end
endDate = 60 * 2 * time.Second
endDate = 60 * 10 * time.Second
)
var cliKey = "clients"
......
......@@ -76,7 +76,7 @@ func NewClient(conf *Config) *Client {
client.OnPing(nil)
client.OnPong(nil)
wsSever.hub.AddClient(client)
AppendClient(client.Id,string(SerializeJson(conf)))
AppendClient(client.Id, string(SerializeJson(conf)))
return client
}
......@@ -310,7 +310,7 @@ func GetList(source, userType string) map[string]*Client {
clientData := make(map[string]*Client, 0)
for k, v := range wsSever.hub.clients {
userInfo := strings.Split(k, "_")
if userInfo[0] == source {
if (userInfo[0] == source) || (source == "") {
if userType != "" {
if userInfo[1] == userType {
clientData[k] = v
......@@ -474,7 +474,7 @@ func SaveMsg(msg *SendMsg) {
mqData.EndTime = msg.SendTime
mqData.Promoter = user.Promoter
mqData.Finish = "5"
DelConversation(msg.FromClientId,msg.ToClientId)
DelConversation(msg.FromClientId, msg.ToClientId)
}
if mqData.ProcedureType != 0 {
......@@ -518,11 +518,11 @@ func AppendConversation(conversation *Conversation) {
}
func DelConversation(customerClientId, userClientId string) {
Redis.HDel(convKey, customerClientId + "^" + userClientId)
Redis.HDel(convKey, customerClientId+"^"+userClientId)
return
}
func AppendClient(clientId, data string){
func AppendClient(clientId, data string) {
Redis.HSet(cliKey, clientId, data)
return
}
......
......@@ -18,7 +18,7 @@ var addr2 = flag.String("addr", "127.0.0.1:11001", "http service address")
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
for i := 1; i < 5; i++ {
for i := 1; i < 50; i++ {
go wsClient2(fmt.Sprintf("lA6fUNMamyUBlOokPOeiGg==_1_%d", i))
}
select {}
......
......@@ -76,7 +76,7 @@ func ws(w http.ResponseWriter, r *http.Request) {
userInfo, err := pool.GetClientInfoByToken(headData)
if err != nil {
fmt.Println("用户信息报错:",err)
fmt.Println("用户信息报错:", err)
return
}
......@@ -181,14 +181,21 @@ func ws(w http.ResponseWriter, r *http.Request) {
}
func GetClientList(w http.ResponseWriter, r *http.Request) {
//fmt.Println(wsSever.hub.clients)
data := r.URL.Query()
//req := new(GetClientListReq)
//pool.UnserislizeJson(data, req)
//source := data["source"][0]
reply := pool.GetList(data["source"][0], data["promoter"][0])
fmt.Println("客户端列表:",reply)
return
list := pool.GetList(data["source"][0], data["promoter"][0])
reply := make([]string, 0)
for k := range list {
reply = append(reply, k)
}
resp(w,reply)
}
func resp(w http.ResponseWriter,data interface{}){
w.Header().Set("content-type", "text/json")
w.WriteHeader(200)
w.Write(pool.SerializeJson(data))
}
type GetClientListReq struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment