messages

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	HandleAskHP(msg AskHPMessage)
	HandleAskFoodTaken(msg AskFoodTakenMessage)
	HandleAskIntendedFoodTaken(msg AskIntendedFoodIntakeMessage)
	HandleRequestLeaveFood(msg RequestLeaveFoodMessage)
	HandleRequestTakeFood(msg RequestTakeFoodMessage)
	HandleResponse(msg BoolResponseMessage)
	HandleStateFoodTaken(msg StateFoodTakenMessage)
	HandleStateHP(msg StateHPMessage)
	HandleStateIntendedFoodTaken(msg StateIntendedFoodIntakeMessage)
}

type AskFoodTakenMessage

type AskFoodTakenMessage struct {
	*BaseMessage
}

func NewAskFoodTakenMessage

func NewAskFoodTakenMessage(SenderFloor int) *AskFoodTakenMessage

func (*AskFoodTakenMessage) Reply

func (msg *AskFoodTakenMessage) Reply(senderFloor int, food int) StateMessage

func (*AskFoodTakenMessage) Visit

func (msg *AskFoodTakenMessage) Visit(a Agent)

type AskHPMessage

type AskHPMessage struct {
	*BaseMessage
}

func NewAskHPMessage

func NewAskHPMessage(senderFloor int) *AskHPMessage

func (*AskHPMessage) Reply

func (msg *AskHPMessage) Reply(senderFloor int, hp int) StateMessage

func (*AskHPMessage) Visit

func (msg *AskHPMessage) Visit(a Agent)

type AskIntendedFoodIntakeMessage

type AskIntendedFoodIntakeMessage struct {
	*BaseMessage
}

func NewAskIntendedFoodIntakeMessage

func NewAskIntendedFoodIntakeMessage(senderFloor int) *AskIntendedFoodIntakeMessage

func (*AskIntendedFoodIntakeMessage) Reply

func (msg *AskIntendedFoodIntakeMessage) Reply(senderFloor int, food int) StateMessage

func (*AskIntendedFoodIntakeMessage) Visit

func (msg *AskIntendedFoodIntakeMessage) Visit(a Agent)

type AskMessage

type AskMessage interface {
	Message
	Reply(senderFloor int, food int) StateMessage
}

type BaseMessage

type BaseMessage struct {
	// contains filtered or unexported fields
}

func NewBaseMessage

func NewBaseMessage(senderFloor int, messageType MessageType) *BaseMessage

func (BaseMessage) MessageType

func (msg BaseMessage) MessageType() MessageType

func (BaseMessage) SenderFloor

func (msg BaseMessage) SenderFloor() int

type BoolResponseMessage

type BoolResponseMessage struct {
	*BaseMessage
	// contains filtered or unexported fields
}

func NewResponseMessage

func NewResponseMessage(senderFloor int, response bool) *BoolResponseMessage

func (*BoolResponseMessage) Response

func (msg *BoolResponseMessage) Response() bool

func (*BoolResponseMessage) Visit

func (msg *BoolResponseMessage) Visit(a Agent)

type Message

type Message interface {
	MessageType() MessageType
	SenderFloor() int
	Visit(a Agent)
}

type MessageType

type MessageType int
const (
	AskFoodTaken MessageType = iota + 1
	AskHP
	AskFoodOnPlatform
	AskIntendedFoodIntake
	AskIdentity
	StateFoodTaken
	StateHP
	StateFoodOnPlatform
	StateIntendedFoodIntake
	StateIdentity
	StateResponse
	RequestLeaveFood
	RequestTakeFood
	Response
)

type RequestLeaveFoodMessage

type RequestLeaveFoodMessage struct {
	*BaseMessage
	// contains filtered or unexported fields
}

func NewRequestLeaveFoodMessage

func NewRequestLeaveFoodMessage(SenderFloor int, food int) *RequestLeaveFoodMessage

func (*RequestLeaveFoodMessage) Reply

func (msg *RequestLeaveFoodMessage) Reply(senderFloor int, response bool) ResponseMessage

func (*RequestLeaveFoodMessage) Request

func (msg *RequestLeaveFoodMessage) Request() int

func (*RequestLeaveFoodMessage) Visit

func (msg *RequestLeaveFoodMessage) Visit(a Agent)

type RequestMessage

type RequestMessage interface {
	Message
	Request() int
	Reply(senderFloor int, response bool) ResponseMessage
}

type RequestTakeFoodMessage

type RequestTakeFoodMessage struct {
	*BaseMessage
	// contains filtered or unexported fields
}

func NewRequestTakeFoodMessage

func NewRequestTakeFoodMessage(SenderFloor int, food int) *RequestTakeFoodMessage

func (*RequestTakeFoodMessage) Reply

func (msg *RequestTakeFoodMessage) Reply(senderFloor int, response bool) ResponseMessage

func (*RequestTakeFoodMessage) Request

func (msg *RequestTakeFoodMessage) Request() int

func (*RequestTakeFoodMessage) Visit

func (msg *RequestTakeFoodMessage) Visit(a Agent)

type ResponseMessage

type ResponseMessage interface {
	Message
	Response() bool
}

type StateFoodTakenMessage

type StateFoodTakenMessage struct {
	*BaseMessage
	// contains filtered or unexported fields
}

func NewStateFoodTakenMessage

func NewStateFoodTakenMessage(senderFloor int, foodTaken int) *StateFoodTakenMessage

func (*StateFoodTakenMessage) Statement

func (msg *StateFoodTakenMessage) Statement() int

func (*StateFoodTakenMessage) Visit

func (msg *StateFoodTakenMessage) Visit(a Agent)

type StateHPMessage

type StateHPMessage struct {
	*BaseMessage
	// contains filtered or unexported fields
}

func NewStateHPMessage

func NewStateHPMessage(senderFloor int, hp int) *StateHPMessage

func (*StateHPMessage) Statement

func (msg *StateHPMessage) Statement() int

func (*StateHPMessage) Visit

func (msg *StateHPMessage) Visit(a Agent)

type StateIntendedFoodIntakeMessage

type StateIntendedFoodIntakeMessage struct {
	*BaseMessage
	// contains filtered or unexported fields
}

func NewStateIntendedFoodIntakeMessage

func NewStateIntendedFoodIntakeMessage(SenderFloor int, intendedFood int) *StateIntendedFoodIntakeMessage

func (*StateIntendedFoodIntakeMessage) Statement

func (msg *StateIntendedFoodIntakeMessage) Statement() int

func (*StateIntendedFoodIntakeMessage) Visit

func (msg *StateIntendedFoodIntakeMessage) Visit(a Agent)

type StateMessage

type StateMessage interface {
	Message
	Statement() int
}

Jump to

Keyboard shortcuts

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