711c4b4b7b
* Cleanup shutdown and peers subscribe this has errors currently, need to figure out data race * fixed data race finally.... * getclaimbyid and search * hook jsonrpc peers subcribe into current federation * cleanup some peers stuff * remove commented code * tie into session manager in jsonrpc peers subscribe * use int for port args * cleanup and fix a bunch of compiler warnings * use logrus everywhere * cleanup test
39 lines
840 B
Go
39 lines
840 B
Go
package server
|
|
|
|
import (
|
|
"errors"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type PeersService struct {
|
|
Server *Server
|
|
// needed for subscribe/unsubscribe
|
|
sessionMgr *sessionManager
|
|
session *session
|
|
}
|
|
|
|
type PeersSubscribeReq struct {
|
|
Ip string `json:"ip"`
|
|
Host string `json:"host"`
|
|
Details []string `json:"details"`
|
|
}
|
|
|
|
type PeersSubscribeResp string
|
|
|
|
// Features is the json rpc endpoint for 'server.peers.subcribe'.
|
|
func (t *PeersService) Subscribe(req *PeersSubscribeReq, res **PeersSubscribeResp) error {
|
|
log.Println("PeersSubscribe")
|
|
// var port = "50001"
|
|
|
|
// FIXME: Get the actual port from the request details
|
|
|
|
if t.sessionMgr == nil || t.session == nil {
|
|
*res = nil
|
|
return errors.New("no session, rpc not supported")
|
|
}
|
|
t.sessionMgr.peersSubscribe(t.session, true /*subscribe*/)
|
|
|
|
*res = nil
|
|
return nil
|
|
}
|