git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 5915f4b12de689ba1985efe90c4181b4e774977c

moved more to port manager

wanderer committed on 7/5/2017, 3:57:33 AM
Parent: 1aa22ba2b0c933edd5df2a76889d2cd6751baca0

Files changed

kernel.jschanged
portManager.jschanged
kernel.jsView
@@ -79,9 +79,9 @@
7979
8080 const responsePort = message.responsePort
8181 delete message.responsePort
8282
83- message.ports.forEach(port => this.ports._unboundPorts.add(port))
83+ this.ports.addReceivedPorts(message)
8484 message._hops++
8585
8686 if (message.constructor === DeleteMessage) {
8787 this.ports._delete(message.fromName)
@@ -133,13 +133,9 @@
133133 * @param {*} data
134134 */
135135 createMessage (opts) {
136136 const message = new Message(opts)
137- for (const port of message.ports) {
138- if (this.ports.isBound(port)) {
139- throw new Error('message must not contain bound ports')
140- }
141- }
137+ this.ports.checkSendingPorts(message)
142138 return message
143139 }
144140
145141 /**
portManager.jsView
@@ -249,5 +249,17 @@
249249
250250 removeSentPorts (message) {
251251 message.ports.forEach(port => this._unboundPorts.delete(port))
252252 }
253+
254+ addReceivedPorts (message) {
255+ message.ports.forEach(port => this._unboundPorts.add(port))
256+ }
257+
258+ checkSendingPorts(message) {
259+ for (const port of message.ports) {
260+ if (this.isBound(port)) {
261+ throw new Error('message must not contain bound ports')
262+ }
263+ }
264+ }
253265 }

Built with git-ssb-web