Commit 1034e760 authored by LUXEY Adrien's avatar LUXEY Adrien
Browse files

finally seems to work

parent ddaf07dc
......@@ -137,8 +137,11 @@ func (st *StoryTeller) AddInteractionReceiver(receiver chan<- Item) {
func (st *StoryTeller) NotifyInteractionReceivers(items ...Item) {
for _, it := range items {
for _, ch := range st.interactionReceviers {
go func() { ch <- it }()
for i, ch := range st.interactionReceviers {
go func(ch chan<- Item, it Item) {
ch <- it
st.debug.Printf("Successfully notified receiver #%d of interaction: %v\n", i, it)
}(ch, it)
}
}
}
......@@ -290,6 +293,9 @@ func (st *StoryTeller) handleRequest(mess transport.Message) {
// We update our sequence with the received payload
newInteractions := st.sequence.Merge(recSeq)
if len(newInteractions) > 0 {
st.NotifyInteractionReceivers(newInteractions...)
}
// Just a little logging
if st.csv != nil {
......@@ -298,7 +304,6 @@ func (st *StoryTeller) handleRequest(mess transport.Message) {
if len(newInteractions) == 0 {
st.nUselessMessages++
} else {
go st.NotifyInteractionReceivers(newInteractions...)
// If my sequence was updated, add a csv line
go st.addLogLine(time.Now(), payload.Sender)
}
......@@ -387,13 +392,15 @@ func (st *StoryTeller) handleAnswer(mess transport.Message) {
// We update our sequence with the received payload
newInteractions := st.sequence.Merge(recSeq)
if len(newInteractions) > 0 {
st.NotifyInteractionReceivers(newInteractions...)
}
if st.csv != nil {
st.nMessages++
if len(newInteractions) == 0 {
st.nUselessMessages++
} else {
st.NotifyInteractionReceivers(newInteractions...)
// If my sequence was updated and we log, add a csv line
go st.addLogLine(time.Now(), payload.Sender)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment