|
@@ -53,14 +53,13 @@ func (c *ExecutionContext) StartInboundChannel() chan PlayerEvent {
|
53
|
53
|
c.outbound = c.outbound
|
54
|
54
|
|
55
|
55
|
go func() {
|
56
|
|
- //inbound event buffer to protect the event distributor from long running tasks
|
57
|
|
- // the alternative is to run each inbound event in a separate goroutine
|
58
|
|
- // but that has potential problems (ie, two emits arrive in order. the first one
|
59
|
|
- // requires an extra DB lookup to sort out context. now the second one ends up
|
60
|
|
- // sending its output event before the first, and the client sees things backwards
|
61
|
|
- // this isn't just an edge case, it happens quite frequently.
|
62
|
|
- // The alternative is to buffer inbound events, which is the safest, as it doesn't
|
63
|
|
- // impact the eventdistributor.
|
|
56
|
+
|
|
57
|
+ // An inbound event buffer to protect the event distributor from long
|
|
58
|
+ // running tasks. The alternative is to run each inbound event in a
|
|
59
|
+ // separate goroutine but that has potential problems (ie, two emits
|
|
60
|
+ // arrive in order; the first one requires an extra DB lookup to sort
|
|
61
|
+ // out context. Now the second one ends up sending its output event
|
|
62
|
+ // before the first, and the client sees things backwards.
|
64
|
63
|
|
65
|
64
|
queue := make([]*PlayerEvent, 0)
|
66
|
65
|
running := true
|
|
@@ -90,7 +89,6 @@ func (c *ExecutionContext) StartInboundChannel() chan PlayerEvent {
|
90
|
89
|
}
|
91
|
90
|
// closure of c.inbound is the signal from the event distributor that we need to die.
|
92
|
91
|
// we then close inboundBuffer to tell the event goroutine to die
|
93
|
|
- fmt.Println("close(inboundBuffer)")
|
94
|
92
|
close(inboundBuffer)
|
95
|
93
|
}()
|
96
|
94
|
|
|
@@ -103,9 +101,7 @@ func (c *ExecutionContext) StartInboundChannel() chan PlayerEvent {
|
103
|
101
|
c.HandleEvent(event)
|
104
|
102
|
}
|
105
|
103
|
// and finally we tell the event distributor to delete us.
|
106
|
|
- fmt.Println("Sending EventTypeTeardownComplete")
|
107
|
104
|
c.outbound <- PlayerEvent{src: c.actor.ID, dst: c.actor.ID, messageType: EventTypeTeardownComplete}
|
108
|
|
-
|
109
|
105
|
}()
|
110
|
106
|
|
111
|
107
|
return c.inbound
|