...

Package mesh

import "github.com/Diarkis/diarkis/mesh/lib/reliable"
Overview
Index

Overview ▾

Variables

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

func Command(commandID uint16, callback func(map[string]interface{}) (map[string]interface{}, error))

Command Registers a packet handler as a command

func Config

func Config()

Config Loads a configuration file into memory

func ExecuteCmdLocally

func ExecuteCmdLocally(cmd uint16, data map[string]interface{})

ExecuteCmdLocally Executes commands locally

func IsCommandDuplicate

func IsCommandDuplicate(commandID uint16) bool

IsCommandDuplicate returns true if commandID is used elsewhere

func IsTimeoutError

func IsTimeoutError(err error) bool

IsTimeoutError returns true if the error is a retry timeout of reliable message

func Rcv

func Rcv(_packet []byte, senderNode net.Addr)

Rcv Receives mesh network message packet

func Send

func Send(commandID uint16, node net.Addr, data map[string]interface{})

Send Sends a packet

func SendAck

func SendAck(id string, senderNode net.Addr)

SendAck Sends an ack packet

func SendRequest

func SendRequest(commandID uint16, node net.Addr, data map[string]interface{}, callback func(error, map[string]interface{}))

SendRequest Sends a request packet

func SetSendMethod

func SetSendMethod(method func([]byte, net.Addr) error)

SetSendMethod [INTERNAL USE ONLY] used in udp.go

func SetServer

func SetServer(_server net.PacketConn)

SetServer Internal use ONLY

func Stop

func Stop()

Stop stops the reliable server

func USend

func USend(commandID uint16, nodeAddr net.Addr, data map[string]interface{}) bool

USend Sends an unreliable packet

type Message

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
}