Skip to content

Commit

Permalink
Merge pull request #11 from MattSScott/fancy-print
Browse files Browse the repository at this point in the history
added formatted printing to main
  • Loading branch information
MattSScott authored Sep 20, 2023
2 parents 713a0f4 + 5b9149b commit e37f7b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/main/server/baseServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (bs *BaseServer[T]) RunMessagingSession() {
for _, msg := range allMessages {
recipients := msg.GetRecipients()
for _, recip := range recipients {
if agent.GetID() == recip.GetID() {
continue
}
msg.Accept(recip)
}
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/testing/testAgents/helloAgent/helloAgent.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ func (ha *HelloAgent) GetAllMessages(availableAgents []baseExtendedAgent.IExtend
}

func (ha *HelloAgent) CreateGreetingMessage(recips []baseExtendedAgent.IExtendedAgent) baseExtendedAgent.GreetingMessage {
msgText := fmt.Sprintf("%s said: '%s'", ha.GetID(), ha.GetPhrase())
fmt.Println(msgText)
return baseExtendedAgent.CreateGreetingMessage(ha, recips, ha.GetPhrase())
}

func (ha *HelloAgent) HandleGreetingMessage(msg baseExtendedAgent.GreetingMessage) {
if msg.GetGreeting() == "wello" {
fmt.Println(ha.GetID(), " responded: 'horld'")
respText := fmt.Sprintf("%s responded: 'horld'", ha.GetID())
fmt.Println(respText)
}
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/testing/testAgents/worldAgent/worldAgent.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ func (wa *WorldAgent) GetAllMessages(availableAgents []baseExtendedAgent.IExtend
}

func (wa *WorldAgent) CreateGreetingMessage(recips []baseExtendedAgent.IExtendedAgent) baseExtendedAgent.GreetingMessage {
msgText := fmt.Sprintf("%s said: '%s'", wa.GetID(), wa.GetPhrase())
fmt.Println(msgText)
return baseExtendedAgent.CreateGreetingMessage(wa, recips, wa.GetPhrase())
}

func (wa *WorldAgent) HandleGreetingMessage(msg baseExtendedAgent.GreetingMessage) {
if msg.GetGreeting() == "hello" {
fmt.Println(wa.GetID(), " responded: 'world'")
respText := fmt.Sprintf("%s responded: 'world'", wa.GetID())
fmt.Println(respText)
}
}

Expand Down

0 comments on commit e37f7b0

Please sign in to comment.