Преглед изворни кода

Bit of reformatting, debug code removal, and doc update

Keelan Lightfoot пре 8 година
родитељ
комит
e8b37ac68b
5 измењених фајлова са 11 додато и 25 уклоњено
  1. 1
    0
      README.md
  2. 0
    2
      db.go
  3. 1
    6
      event_distributor.go
  4. 7
    11
      execution_context.go
  5. 2
    6
      object.go

+ 1
- 0
README.md Прегледај датотеку

@@ -53,6 +53,7 @@ This is the stuff that you use the most when you're not building things.
53 53
 	enter <object reference>
54 54
 	leave
55 55
 	quit
56
+	@force <object reference>=<command>
56 57
 	
57 58
 
58 59
 ### Building Commands

+ 0
- 2
db.go Прегледај датотеку

@@ -348,8 +348,6 @@ func (s *DB) txStoreObject(b *bolt.Bucket, o Object, id DBRef) error {
348 348
 
349 349
 	buf, err := json.Marshal(o)
350 350
 
351
-	//fmt.Println("txStoreObject", id.String(), string(buf))
352
-
353 351
 	if err != nil {
354 352
 		return err
355 353
 	}

+ 1
- 6
event_distributor.go Прегледај датотеку

@@ -106,11 +106,10 @@ func (e *EventDistributor) Run() {
106 106
 				}
107 107
 			}
108 108
 			reg := e.players[sub.playerID]
109
-			fmt.Println("connection id", sub.connectionID)
110 109
 			reg.connInbound[sub.connectionID] = sub.inbound
111 110
 			sub.outbound <- outbound
112 111
 		case event := <-outbound: // message
113
-			fmt.Printf("received message src:%d dest:%d type: %d\n", event.src, event.dst, event.messageType)
112
+			//fmt.Printf("received message src:%d dest:%d type: %d\n", event.src, event.dst, event.messageType)
114 113
 
115 114
 			destPlayer, validDest := e.players[event.dst]
116 115
 
@@ -120,7 +119,6 @@ func (e *EventDistributor) Run() {
120 119
 			case EventTypeTeardownComplete:
121 120
 				if validDest {
122 121
 					delete(e.players, event.dst)
123
-					fmt.Println("EventTypeTeardownComplete")
124 122
 				}
125 123
 			case EventTypeOutput: // from context to connection
126 124
 				if validDest {
@@ -132,13 +130,10 @@ func (e *EventDistributor) Run() {
132 130
 					e.players[event.dst].connInbound[event.connectionID] <- event
133 131
 				}
134 132
 			case EventTypeTeardown: // comes from client when connection is dropped
135
-				fmt.Println("received EventTypeTeardown")
136 133
 				if validDest {
137 134
 					close(e.players[event.dst].connInbound[event.connectionID])
138 135
 					delete(e.players[event.dst].connInbound, event.connectionID)
139
-					fmt.Println("EventTypeTeardown delete", event.connectionID, "len: ", len(e.players[event.dst].connInbound))
140 136
 					if len(e.players[event.dst].connInbound) == 0 {
141
-						fmt.Println("EventTypeTeardown killing exe")
142 137
 						close(e.players[event.dst].execInbound) // closing the inbound channel signals the exec to stop
143 138
 					}
144 139
 				}

+ 7
- 11
execution_context.go Прегледај датотеку

@@ -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

+ 2
- 6
object.go Прегледај датотеку

@@ -172,20 +172,16 @@ func (o *Object) GetLinkNames(matchType string, exclude DBRefList) []string {
172 172
 
173 173
 	children := o.db.GetChildren(o.ID) // map[DBRef]string
174 174
 
175
+childLoop:
175 176
 	for childID, linkType := range children {
176 177
 		if matchType != "*" && matchType != linkType {
177 178
 			continue
178 179
 		}
179
-		skip := false
180 180
 		for _, excludeID := range exclude {
181 181
 			if excludeID == childID {
182
-				fmt.Println("Skipping ", childID)
183
-				skip = true
182
+				continue childLoop
184 183
 			}
185 184
 		}
186
-		if skip {
187
-			continue
188
-		}
189 185
 		o, found := o.db.Fetch(childID)
190 186
 		if found {
191 187
 			if linkType == "exit" {