github.com/15mga/kiwi@v0.0.2-0.20240324021231-b95d5c3ac751/node.go (about) 1 package kiwi 2 3 import ( 4 "github.com/15mga/kiwi/util" 5 ) 6 7 type ( 8 TSvc = uint16 9 TCode = uint8 10 TSvcCode = uint16 11 NotifyHandler func(pkt IRcvNotice) 12 PacketToStr func(IRcvPkt) string 13 ) 14 15 var ( 16 _Node INode 17 ) 18 19 func Node() INode { 20 return _Node 21 } 22 23 func SetNode(node INode) { 24 _Node = node 25 } 26 27 type INode interface { 28 Init() *util.Err 29 Connect(ip string, port int, svc TSvc, nodeId int64, ver string, head util.M) 30 Disconnect(svc TSvc, id int64) 31 Push(pus ISndPush) 32 PushNode(nodeId int64, pus ISndPush) 33 Request(req ISndRequest) 34 RequestNode(nodeId int64, req ISndRequest) 35 Notify(ntf ISndNotice) 36 ReceiveWatchNotice(nodeId int64, methods []TCode) 37 SendToNode(nodeId int64, bytes []byte, fnErr util.FnErr) 38 } 39 40 type INodeHandler interface { 41 Receive(agent IAgent, bytes []byte) 42 } 43 44 type NodeDialerToBool func(INodeDialer) bool 45 46 type INodeDialer interface { 47 Svc() TSvc 48 NodeId() int64 49 Dialer() IDialer 50 Head() util.M 51 Send(bytes []byte, fnErr util.FnErr) 52 }