RetryCnt used to measure how many mesh network retries are being sent every second
var RetryCnt = 0
SendCnt used to measure how many mesh network packets are being sent every second
var SendCnt = 0
func Command(commandID uint16, callback func(map[string]interface{}) (map[string]interface{}, error))
Command [Deprecated] registers a packet handler as a command
func Config()
Config Loads a configuration file into memory
func CreateReturnBytes(data map[string]interface{}) ([]byte, error)
CreateReturnBytes converts a map into byte array for HandleCommand handler's return value.
func ExecuteCmdLocally(cmd uint16, data map[string]interface{})
ExecuteCmdLocally Executes commands locally
func HandleCommand(cmd uint16, cb func(map[string]interface{}) ([]byte, error))
HandleCommand assigns a callback to handle a mesh network command.
[NOTE] HandleCommand replaces Command
func IsCommandDuplicate(commandID uint16) bool
IsCommandDuplicate returns true if commandID is used elsewhere
func IsTimeoutError(err error) bool
IsTimeoutError returns true if the error is a retry timeout of reliable message
func Rcv(_packet []byte, senderNode net.Addr)
Rcv Receives mesh network message packet
func Send(commandID uint16, node net.Addr, data map[string]interface{})
Send Sends a packet
func SendAck(id string, senderNode net.Addr)
SendAck Sends an ack packet
func SendRequest(commandID uint16, node net.Addr, data map[string]interface{}, callback func(error, map[string]interface{}))
SendRequest Sends a request packet
func SetSendMethod(method func([]byte, net.Addr) error)
SetSendMethod [INTERNAL USE ONLY] used in udp.go
func SetServer(_server net.PacketConn)
SetServer Internal use ONLY
func Stop()
Stop stops the reliable server
func USend(commandID uint16, nodeAddr net.Addr, data map[string]interface{}) bool
USend Sends an unreliable packet
Message Data structure of Message
type Message struct { Acked bool Callbacked bool ID string RetryCount int64 SentTime int64 Node net.Addr Packet []byte Callback func(error, map[string]interface{}) Invalid bool // this is sent to true when retry fails and will be ignored there after }