|
@@ -65,7 +65,6 @@ func (e *EventDistributor) OnlinePlayers() DBRefList {
|
65
|
65
|
e.whoChan <- replyChan
|
66
|
66
|
onlinePlayers := <-replyChan
|
67
|
67
|
return onlinePlayers
|
68
|
|
- return DBRefList{}
|
69
|
68
|
}
|
70
|
69
|
|
71
|
70
|
//[client runs quit command]
|
|
@@ -90,6 +89,7 @@ func (e *EventDistributor) Run() {
|
90
|
89
|
e.players = make(map[DBRef]*playerRegistration)
|
91
|
90
|
|
92
|
91
|
outbound := make(chan PlayerEvent)
|
|
92
|
+ outboundBuffered := EventBuffer(outbound)
|
93
|
93
|
|
94
|
94
|
forceContext := NewForceContext(e, e.db, outbound)
|
95
|
95
|
forceInbound := forceContext.StartInboundChannel()
|
|
@@ -98,11 +98,11 @@ func (e *EventDistributor) Run() {
|
98
|
98
|
|
99
|
99
|
select {
|
100
|
100
|
case replyChan := <-e.whoChan:
|
101
|
|
- onlinePlayers := make(DBRefList, 0)
|
102
|
|
- for playerID, _ := range e.players {
|
103
|
|
- onlinePlayers = append(onlinePlayers, playerID)
|
104
|
|
- }
|
105
|
|
- replyChan <- onlinePlayers
|
|
101
|
+ onlinePlayers := make(DBRefList, 0)
|
|
102
|
+ for playerID, _ := range e.players {
|
|
103
|
+ onlinePlayers = append(onlinePlayers, playerID)
|
|
104
|
+ }
|
|
105
|
+ replyChan <- onlinePlayers
|
106
|
106
|
case sub := <-e.subscribeChan:
|
107
|
107
|
|
108
|
108
|
if _, exists := e.players[sub.playerID]; !exists {
|
|
@@ -118,7 +118,7 @@ func (e *EventDistributor) Run() {
|
118
|
118
|
reg := e.players[sub.playerID]
|
119
|
119
|
reg.connInbound[sub.connectionID] = sub.inbound
|
120
|
120
|
sub.outbound <- outbound
|
121
|
|
- case event := <-outbound: // message
|
|
121
|
+ case event := <-outboundBuffered: // message
|
122
|
122
|
//fmt.Printf("received message src:%d dest:%d type: %d\n", event.src, event.dst, event.messageType)
|
123
|
123
|
|
124
|
124
|
destPlayer, validDest := e.players[event.dst]
|