From 7848ce12f101f8e825b01a52e620f75514900ea9 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期三, 11 三月 2020 14:26:11 +0800
Subject: [PATCH] ret cliInfo

---
 mangos.go |   26 +++++++++++++++++++++++---
 pubsub.go |    4 ++++
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/mangos.go b/mangos.go
index dac46e2..4eff568 100644
--- a/mangos.go
+++ b/mangos.go
@@ -13,6 +13,11 @@
 	pubCh        chan Message  //publish msg chan
 	surveyors    gopherdiscovery.StringSet
 
+	svr *gopherdiscovery.DiscoveryServer
+	cli *gopherdiscovery.DiscoveryClient
+
+	cliInfo map[string]interface{}
+
 	recvCh chan Message  //recv msg chan
 }
 
@@ -22,9 +27,8 @@
 	var err error
 	var (
 		defaultOpts = gopherdiscovery.Options{
-			SurveyTime:   3 * time.Second,
-			//RecvDeadline: 3 * time.Second,
-			PollTime:     5 * time.Second,
+			SurveyTime:   1500 * time.Millisecond,
+			PollTime:     2 * time.Second,
 		}
 	)
 
@@ -36,6 +40,7 @@
 		heartBeatUrl: heartBeatUrl,
 		surveyors:    gopherdiscovery.NewStringSet(),
 		pubCh:        make(chan Message, 50),
+		svr: discoveryServer,
 	}
 	var msgCache = make(map[string]Message)
 	//clientMsgCh := make(map[string]chan Message)
@@ -76,6 +81,7 @@
 				}
 
 				pub.surveyors = nodeIds
+				pub.cliInfo = discoveryServer.SvInfo()
 				time.Sleep(10 * time.Millisecond)
 			}
 		}
@@ -101,6 +107,7 @@
 		heartBeatUrl: heartBeatUrl,
 		recvCh: make(chan Message,50),
 		surveyors: gopherdiscovery.NewStringSet(),
+		cli: client,
 	}
 	var receivedCache = make(map[string]string)
 	go func() {
@@ -150,3 +157,16 @@
 func (ps *mangosPubSub) Recv() chan Message {
 	return ps.recvCh
 }
+
+func (ps *mangosPubSub) GetCliInfo() map[string]interface{} {
+	if ps.svr != nil {
+		return ps.cliInfo
+	}
+	return nil
+}
+
+func (ps *mangosPubSub) SetResp(r interface{}) {
+	if ps.cli != nil {
+		ps.cli.SetResp(r)
+	}
+}
\ No newline at end of file
diff --git a/pubsub.go b/pubsub.go
index bb03256..b500907 100644
--- a/pubsub.go
+++ b/pubsub.go
@@ -7,6 +7,10 @@
 	Surveyor() []string
 
 	Recv() chan Message
+
+	GetCliInfo() map[string]interface{}
+
+	SetResp(interface{})
 }
 
 type Message struct {

--
Gitblit v1.8.0