comm

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 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
)
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 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 SendMission

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

func SendRecalculation added in v0.1.1

func SendRecalculation(metadata agentlogic.Agent, selfId string)

func SendReorganization

func SendReorganization(metadata agentlogic.Agent, selfId string)

func SendState

func SendState(state *agentlogic.State)

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 added in v0.1.1

type DiscoveryMessage struct {
	MessageMeta MessageMeta
	Content     agentlogic.Agent
}

type Message

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

type MessageMeta added in v0.1.1

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

type MessageType

type MessageType int

type MissionMessage added in v0.1.1

type MissionMessage struct {
	MessageMeta MessageMeta
	Content     agentlogic.Mission
}

type StateMessage added in v0.1.1

type StateMessage struct {
	MessageMeta MessageMeta
	Content     agentlogic.State
}

type VisualizationChannel

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

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
	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