comm

package module
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 18 Imported by: 0

README

D2D-communication

Documentation

Index

Constants

View Source
const (
	DiscoveryMessageType      = 0
	StateMessageType          = 1
	MissionMessageType        = 2
	ReorganizationMessageType = 3
	RecalculatorMessageType   = 4
	GoalMessageType           = 5
)
View Source
const BufferSize = 128

BufferSize is the number of incoming messages to buffer for each topic.

View Source
const DiscoveryInterval = time.Hour

DiscoveryInterval is how often we re-publish our mDNS records.

View Source
const DiscoveryServiceTag = "D2D_Comunidad"

DiscoveryServiceTag is used in our mDNS advertisements to discover other chat peers.

View Source
const VisualizationAgentType = -133
View Source
const VisualizationMessageType = -13

Variables

View Source
var ChannelVisualization = make(chan Message, BufferSize)
View Source
var DiscoveryChannel = make(chan *DiscoveryMessage, BufferSize)
View Source
var GoalChannel = make(chan *GoalMessage, BufferSize)
View Source
var MissionChannel = make(chan *MissionMessage, BufferSize)
View Source
var RecalculationChannel = make(chan *DiscoveryMessage, BufferSize)
View Source
var ReorganizationChannel = make(chan *DiscoveryMessage, BufferSize)
View Source
var SelfId peer.ID
View Source
var StateChannel = make(chan *StateMessage, BufferSize)

Functions

func AnnounceSelf

func AnnounceSelf(metadata *agentlogic.Agent)

func ClosePath

func ClosePath(disconnectedAgent agentlogic.Agent, messageType MessageType)

func InitCommunicationType

func InitCommunicationType(path string, messageType MessageType)

func InitD2DCommuncation

func InitD2DCommuncation(agentType agentlogic.AgentType)

func SendGoalFound

func SendGoalFound(senderId string, goal agentlogic.Goal, posiition agentlogic.Vector, channelPath string) error

func SendMission

func SendMission(senderId string, mission *agentlogic.Mission, channelPath string) error

func SendRecalculation

func SendRecalculation(metadata agentlogic.Agent, selfId string)

func SendReorganization

func SendReorganization(metadata agentlogic.Agent, selfId string)

func SendState

func SendState(state *agentlogic.State)

func SendVizGoal

func SendVizGoal(goal GoalMessage)

Types

type Channel

type Channel struct {
	// Messages is a channel of messages received from other peers in the chat room
	Messages chan *Message

	Close bool
	// contains filtered or unexported fields
}

Channel represents a subscription to a single PubSub topic. Messages can be published to the topic with Channel.Publish, and received messages are pushed to the Messages channel.

func JoinPath

func JoinPath(ctx context.Context, ps *pubsub.PubSub, selfID peer.ID, path string, roomType MessageType) (*Channel, error)

type DiscoveryMessage

type DiscoveryMessage struct {
	MessageMeta MessageMeta
	Content     agentlogic.Agent
}

type GoalMessage

type GoalMessage struct {
	MessageMeta MessageMeta
	Content     agentlogic.Goal
	Position    agentlogic.Vector
	Poi         string
}

type Message

type Message interface {
	// contains filtered or unexported methods
}

type MessageMeta

type MessageMeta struct {
	MsgType    MessageType
	SenderId   string
	SenderType agentlogic.AgentType
}

type MessageType

type MessageType int

type MissionMessage

type MissionMessage struct {
	MessageMeta MessageMeta
	Content     agentlogic.Mission
}

type StateMessage

type StateMessage struct {
	MessageMeta MessageMeta
	Content     agentlogic.State
}

type VisualizationChannel

type VisualizationChannel struct {
	Messages chan *VisualizationMessage
	// contains filtered or unexported fields
}

func GetVizChannel

func GetVizChannel() *VisualizationChannel

func InitVisualizationMessages

func InitVisualizationMessages(subscribe bool) *VisualizationChannel

type VisualizationMessage

type VisualizationMessage struct {
	MsgType          MessageType
	ContentType      MessageType
	DiscoveryMessage agentlogic.Agent
	StateMessage     agentlogic.State
	MissionMessage   agentlogic.Mission
	GoalMessage      GoalMessage
	SenderId         string
	SenderType       agentlogic.AgentType
	MissionBound     orb.Bound
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL