wangshan 6 жил өмнө
parent
commit
fcec13737a

+ 1 - 1
src/config.json

@@ -9,7 +9,7 @@
 	"strTimeNumber": 30,
 	"elasticsearch": "http://192.168.3.11:9800",
 	"elasticPoolSize": 30,
-	"redisaddrs": "other=192.168.3.18:3379,push=192.168.3.18:3379,pushcache_1=192.168.3.18:3379,pushcache_2_a=192.168.3.18:3379,pushcache_2_b=192.168.3.18:3379,sso=192.168.3.18:3379,session=192.168.3.18:3379,recovery=192.168.3.18:3379",
+	"redisaddrs": "other=192.168.3.18:3379,push=192.168.3.18:3379,pushcache_1=192.168.3.18:3379,pushcache_2_a=192.168.3.18:3379,pushcache_2_b=192.168.3.18:3379,sso=192.168.3.18:3379,session=192.168.3.18:3379,recovery=192.168.3.18:3379,login=192.168.3.11:1712",
 	"webport": "83",
 	"webrpcport": "8084",
 	"weixinrpc": "127.0.0.1:8083",

+ 16 - 0
src/jfw/front/websocket.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"log"
 	//"net/http"
+	"jfw/config"
 	qutil "qfw/util"
 	"qfw/util/redis"
 	"strings"
@@ -50,6 +51,21 @@ func init() {
 		go ms.GC()
 		MapSocketArr[i] = ms
 	}
+	redis.InitRedisLogin(config.Sysconfig["redisaddrs"].(string))
+}
+
+//
+func GetRedisPoolVal() {
+	redis.GetLoginVal("loginCode", GetWsByCode)
+	//	var res string
+	//	for {
+	//		res = redis.GetLoginVal("loginCode")
+	//		if res != "" {
+	//			param := strings.Split(res, ",")
+	//			ok := GetWsByCode(param)
+	//			log.Println("ok:", ok)
+	//		}
+	//	}
 }
 
 //根据代码和ws做映射

+ 1 - 1
src/jfw/modules/weixin/src/config.json

@@ -2,7 +2,7 @@
     "mongodbServers": "192.168.3.18:27080",
     "mongodbPoolSize": "5",
     "mongodbName": "qfw",
-    "redisServers": "sso=192.168.3.18:3379,other=192.168.3.18:3379,jyop_other=192.168.3.18:3379,push=192.168.3.18:3379",
+    "redisServers": "sso=192.168.3.18:3379,other=192.168.3.18:3379,jyop_other=192.168.3.18:3379,push=192.168.3.18:3379,login=192.168.3.11:1712",
     "weixinport": "82",
     "weixinrpcport": "8083",
     "webrpcport": "127.0.0.1:8084",

+ 18 - 2
src/jfw/modules/weixin/src/wx/wx.go

@@ -572,6 +572,8 @@ func CheckQmxUser(newUser *map[string]interface{}, UnionId string) (b bool, qmxi
 }
 
 //关注事件处理
+var loginWxPool = make(chan bool, 1)
+
 func Subscribe(w ResponseWriter, r *Request) {
 	defer util.Catch()
 	openid := r.FromUserName
@@ -771,8 +773,15 @@ func Subscribe(w ResponseWriter, r *Request) {
 		go JyopenScanRpc([]string{source, openid})
 	} else {
 		if pccodepre != "32" {
+			loginWxPool <- true
+			go func() {
+				defer func() {
+					<-loginWxPool
+				}()
+				redis.SetLoginVal("loginCode", source+","+openid)
+			}()
 			//修改为rpc回调
-			go SendScanRpc([]string{source, openid})
+			//go SendScanRpc([]string{source, openid})
 		}
 	}
 	//redis.Put("sso", "p_userlogs_"+source, openid, 600)
@@ -1031,8 +1040,15 @@ func ScanHandler(w ResponseWriter, r *Request) {
 			go JyopenScanRpc([]string{r.EventKey, openid})
 		} else {
 			if pccodepre != "32" {
+				loginWxPool <- true
+				go func() {
+					defer func() {
+						<-loginWxPool
+					}()
+					go redis.SetLoginVal("loginCode", r.EventKey+","+openid)
+				}()
 				//修改为rpc回调
-				go SendScanRpc([]string{r.EventKey, openid})
+				//go SendScanRpc([]string{r.EventKey, openid})
 			}
 		}
 	} else {

+ 4 - 0
src/main.go

@@ -56,6 +56,10 @@ func main() {
 			log.Println("ListenAndServe: ", err)
 		}
 	}()
+
+	go func() {
+		front.GetRedisPoolVal()
+	}()
 	//开启web
 	/*
 		config, err := xweb.SimpleTLSConfig("213974579280616.pem", "213974579280616.key")