20,741
edits
m (→JavaScript port: re-introduce emesary namespace) |
|||
Line 178: | Line 178: | ||
{{WIP}} | {{WIP}} | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> //--------------------------------------------------------------------------- | ||
// | // | ||
// Title : EMESARY inter-object communication | // Title : EMESARY inter-object communication | ||
Line 214: | Line 213: | ||
return Object.create(parent); | return Object.create(parent); | ||
} | } | ||
var emesary = (function() { | |||
var Transmitter = | var Transmitter = | ||
Line 372: | Line 373: | ||
}; | }; | ||
return { | |||
Transmitter: Transmitter, | |||
Notification: Notification, | |||
Recipient: Recipient | |||
}; | |||
})(); | |||
// | // | ||
// Instantiate a Global Transmitter | // Instantiate a Global Transmitter | ||
var GlobalTransmitter = Transmitter.new("GlobalTransmitter"); | var GlobalTransmitter = emesary.Transmitter.new("GlobalTransmitter"); | ||
Line 401: | Line 409: | ||
new: function(_value) | new: function(_value) | ||
{ | { | ||
var new_class = Notification.new("TestNotification", _value); | var new_class = emesary.Notification.new("TestNotification", _value); | ||
return new_class; | return new_class; | ||
}, | }, | ||
Line 409: | Line 417: | ||
new: function(_value) | new: function(_value) | ||
{ | { | ||
var new_class = Notification.new("TestNotProcessedNotification", _value); | var new_class = emesary.Notification.new("TestNotProcessedNotification", _value); | ||
return new_class; | return new_class; | ||
}, | }, | ||
Line 417: | Line 425: | ||
new: function(_value, _x, _y, _z) | new: function(_value, _x, _y, _z) | ||
{ | { | ||
var new_class = Notification.new("RadarReturnNotification", _value); | var new_class = emesary.Notification.new("RadarReturnNotification", _value); | ||
new_class.x = _x; | new_class.x = _x; | ||
new_class.y = _y; | new_class.y = _y; | ||
Line 429: | Line 437: | ||
new: function(_ident) | new: function(_ident) | ||
{ | { | ||
var new_class = Recipient.new(_ident); | var new_class = emesary.Recipient.new(_ident); | ||
console.log(new_class); | console.log(new_class); | ||
new_class.count = 0; | new_class.count = 0; | ||
Line 437: | Line 445: | ||
{ | { | ||
this.count = this.count + 1; | this.count = this.count + 1; | ||
return Transmitter.ReceiptStatus_OK; | return emesary.Transmitter.ReceiptStatus_OK; | ||
} | } | ||
return Transmitter.ReceiptStatus_NotProcessed; | return emesary.Transmitter.ReceiptStatus_NotProcessed; | ||
}; | }; | ||
return new_class; | return new_class; | ||
Line 449: | Line 457: | ||
new: function(_ident) | new: function(_ident) | ||
{ | { | ||
var new_class = Recipient.new(_ident); | var new_class = emesary.Recipient.new(_ident); | ||
new_class.Receive = function(notification) | new_class.Receive = function(notification) | ||
{ | { | ||
Line 456: | Line 464: | ||
print(" :: Test recipient ",this.Ident, " recv:",notification.Type," ",notification.Value); | print(" :: Test recipient ",this.Ident, " recv:",notification.Type," ",notification.Value); | ||
print(" :: ",notification.x, " ", notification.y, " ", notification.z); | print(" :: ",notification.x, " ", notification.y, " ", notification.z); | ||
return Transmitter.ReceiptStatus_OK; | return emesary.Transmitter.ReceiptStatus_OK; | ||
} | } | ||
return Transmitter.ReceiptStatus_NotProcessed; | return emesary.Transmitter.ReceiptStatus_NotProcessed; | ||
}; | }; | ||
return new_class; | return new_class; | ||
Line 519: | Line 527: | ||
{ | { | ||
var rv = GlobalTransmitter.NotifyAll(TestNotification.new("Test notification")); | var rv = GlobalTransmitter.NotifyAll(TestNotification.new("Test notification")); | ||
return !Transmitter.IsFailed(rv) && rv != Transmitter.ReceiptStatus_NotProcessed && tt.count == 1; | return !emesary.Transmitter.IsFailed(rv) && rv != emesary.Transmitter.ReceiptStatus_NotProcessed && tt.count == 1; | ||
}); | }); | ||
Line 544: | Line 552: | ||
{ | { | ||
var rv = GlobalTransmitter.NotifyAll(TestNotification.new("Test notification")); | var rv = GlobalTransmitter.NotifyAll(TestNotification.new("Test notification")); | ||
return !Transmitter.IsFailed(rv) && rv != Transmitter.ReceiptStatus_NotProcessed && tt.count == tt_count; | return !emesary.Transmitter.IsFailed(rv) && rv != emesary.Transmitter.ReceiptStatus_NotProcessed && tt.count == tt_count; | ||
}); | }); | ||
Line 552: | Line 560: | ||
{ | { | ||
var rv = GlobalTransmitter.NotifyAll(TestNotProcessedNotification.new("Not Processed")); | var rv = GlobalTransmitter.NotifyAll(TestNotProcessedNotification.new("Not Processed")); | ||
return rv == Transmitter.ReceiptStatus_NotProcessed; | return rv == emesary.Transmitter.ReceiptStatus_NotProcessed; | ||
}); | }); | ||