From d3235afbf6390ec478dc83550faf0655fdfdc756 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期三, 03 二月 2021 17:08:52 +0800
Subject: [PATCH] fix

---
 micronode.go |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/micronode.go b/micronode.go
index 03316b9..3d83727 100644
--- a/micronode.go
+++ b/micronode.go
@@ -23,7 +23,7 @@
 }
 
 func NewMicroNode(ctx context.Context,q chan os.Signal, serverId string, reg *RegisterInfo, fnLog func(v ...interface{})) (*MicroNode, error){
-	conf := NewConfig(KEY_REGISTER,512,5,1000,100,1000, fnLog)
+	conf := NewConfig(KEY_REGISTER,512,5,1000,1000,1000, fnLog)
 	handle, err := Register(ctx, q, conf, reg)
 	if err != nil {
 		return nil, err
@@ -106,6 +106,8 @@
 				//鏀跺埌鍏跺畠杩涚▼鐨勮姹傛秷鎭�
 				go ms.serve(msgR, keyR)
 			}
+
+			time.Sleep(50 * time.Millisecond)
 		}
 	}
 }
@@ -132,6 +134,10 @@
 	}
 
 	return ms.handle.Request(serverId, msgR, milliSecs)
+}
+
+func (ms *MicroNode) RequestOnly(rData []byte, nodes []bhomebus.NetNode) ([]byte, error) {
+	return ms.handle.RequestOnly(rData, nodes)
 }
 
 //鑾峰彇鏈満涓煇涓�涓富棰樼殑 key  锛堢粨鏋滃彧鏈変竴涓厓绱狅級
@@ -189,25 +195,30 @@
 	}
 
 	var reqBody Request
+	var ri *Reply
 	err := json.Unmarshal(msgR.Body, &reqBody)
 	if err != nil {
 		ms.printLog("serve unmarshal msgR.Body err:", err)
-		return
-	}
-
-	ms.printLog("reqBody:", reqBody, "to key: ", p)
-	var ri *Reply
-	if f,ok := ms.handlers[reqBody.Path];ok {
-		ri = f(&reqBody)
-		ms.printLog("call funcMap f,reply:", *ri)
+		ri = &Reply {
+			Msg: err.Error(),
+		}
 	} else {
-		ms.printLog("ms.funcMap not eixst path")
-		ri = &Reply{
-			Success: false,
-			Msg: "璇锋眰鐨勬帴鍙d笉瀛樺湪锛岃妫�鏌rl",
-			Data: "璇锋眰鐨勬帴鍙d笉瀛樺湪锛岃妫�鏌rl",
+		ms.printLog("reqBody Path:", reqBody.Path, " contentType:", reqBody.ContentType, " formMap:",reqBody.FormMap, " postFormMap:", reqBody.PostFormMap, "to key: ", p)
+
+		if f,ok := ms.handlers[reqBody.Path];ok {
+			reqBody.SrcProc = msgR.SrcProc
+			ri = f(&reqBody)
+			ms.printLog("call funcMap f,reply:", *ri)
+		} else {
+			ms.printLog("ms.funcMap not eixst path: ", reqBody.Path)
+			ri = &Reply{
+				Success: false,
+				Msg: "璇锋眰鐨勬帴鍙d笉瀛樺湪锛岃妫�鏌rl",
+				Data: "璇锋眰鐨勬帴鍙d笉瀛樺湪锛岃妫�鏌rl",
+			}
 		}
 	}
+
 	retErr := ms.handle.Reply(p, ri)
 	if retErr != nil {
 		ms.printLog("retErr:", retErr)

--
Gitblit v1.8.0