|
@@ -0,0 +1,50 @@
|
|
|
|
+package p
|
|
|
|
+
|
|
|
|
+import (
|
|
|
|
+ "encoding/json"
|
|
|
|
+ "net/rpc"
|
|
|
|
+ "sync"
|
|
|
|
+
|
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
+ "github.com/donnie4w/go-logger/logger"
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+//
|
|
|
|
+func SendPcHelper(address string, m map[string]interface{}) bool {
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ var repl string
|
|
|
|
+ client, err := rpc.DialHTTP("tcp", address)
|
|
|
|
+ if err != nil {
|
|
|
|
+ logger.Error(err.Error())
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ defer client.Close()
|
|
|
|
+ b, _ := json.Marshal(m)
|
|
|
|
+ err = client.Call("Service.PushMsg", b, &repl)
|
|
|
|
+ if err != nil {
|
|
|
|
+ logger.Error(err.Error())
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ return repl == "y"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//
|
|
|
|
+func LoadPcHelperAllOnLine(address string, r *sync.Map) int {
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ var repl []string
|
|
|
|
+ client, err := rpc.DialHTTP("tcp", address)
|
|
|
|
+ if err != nil {
|
|
|
|
+ logger.Error(err.Error())
|
|
|
|
+ return 0
|
|
|
|
+ }
|
|
|
|
+ defer client.Close()
|
|
|
|
+ err = client.Call("Service.AllOnLine", "", &repl)
|
|
|
|
+ if err != nil {
|
|
|
|
+ logger.Error(err.Error())
|
|
|
|
+ return 0
|
|
|
|
+ }
|
|
|
|
+ for _, v := range repl {
|
|
|
|
+ r.Store(v, true)
|
|
|
|
+ }
|
|
|
|
+ return len(repl)
|
|
|
|
+}
|