1
0
Fork 0

Fix so that the callsign is a method as most of the MP properties probably won't be fully populated when the incoming bridge is created.

This commit is contained in:
Richard Harrison 2016-04-16 15:14:16 +02:00
parent db7ddba8ba
commit 1efe01a452

View file

@ -116,7 +116,7 @@ var OutgoingMPBridge =
if (notification.FromIncomingBridge)
return emesary.Transmitter.ReceiptStatus_NotProcessed;
print("Receive ",notification.NotificationType," ",notification.Ident);
#print("Receive ",notification.NotificationType," ",notification.Ident);
for (var idx = 0; idx < size(me.NotificationsToBridge); idx += 1)
{
if(me.NotificationsToBridge[idx].NotificationType == notification.NotificationType)
@ -230,14 +230,16 @@ var IncomingMPBridge =
new_class.Connect = func(_root)
{
me.MpVariable = _root~"sim/multiplay/generic/string["~new_class.MPidx~"]";
me.Callsign = getprop(_root~"callsign");
print("bridge ",me.MpVariable, " callsign ",me.Callsign);
me.CallsignPath = _root~"callsign";
setlistener(me.MpVariable, func(v)
{
me.ProcessIncoming(v.getValue());
});
};
new_class.GetCallsign = func
{
return getprop(me.CallsignPath);
};
new_class.AddMessage = func(m)
{
append(me.NotificationsToBridge, m);
@ -275,10 +277,8 @@ var IncomingMPBridge =
{
var msg = me.NotificationsToBridge[msg_type_id];
var msg_notify = encoded_notification[3];
print("received idx=",msg_idx," ",msg_type_id,":",msg.NotificationType);
if(msg_idx <= me.IncomingMessageIndex)
print(" **Already processed");
else
# print("received idx=",msg_idx," ",msg_type_id,":",msg.NotificationType);
if (msg_idx > me.IncomingMessageIndex)
{
# raise notification
var bridged_notification = msg; #emesary.Notification.new(msg.NotificationType,"BridgedMessage");
@ -289,7 +289,6 @@ var IncomingMPBridge =
for (var bpi = 0; bpi < size(encvals); bpi += 1) {
if (bpi < size(bridgedProperties)) {
var bp = bridgedProperties[bpi];
print("encval ",bpi,"=",encvals[bpi]);
if (encvals[bpi] != ";" and encvals[bpi] != "") {
var bp = bridgedProperties[bpi];
bp.setValue(encvals[bpi]);
@ -302,7 +301,7 @@ var IncomingMPBridge =
if (bridged_notification.Ident == "none")
bridged_notification.Ident = "mp-bridge";
bridged_notification.FromIncomingBridge = 1;
bridged_notification.Callsign = me.Callsign;
bridged_notification.Callsign = me.GetCallsign();
me.Transmitter.NotifyAll(bridged_notification);
me.IncomingMessageIndex = msg_idx;
}
@ -336,12 +335,13 @@ var IncomingMPBridge =
# Ensure we only handle multiplayer elements
if (find("/multiplayer",path) > 0)
{
print("Callsign path ",path~"/callsign");
var callsign = getprop(path~"/callsign");
print("Creating Emesary MPBridge for ",callsign);
if (callsign == "" or callsign == nil)
callsign = path;
var incomingBridge = emesary_mp_bridge.IncomingMPBridge.new(callsign~"mp", notification_list, 18);
var incomingBridge = emesary_mp_bridge.IncomingMPBridge.new(path, notification_list, 18);
incomingBridge.Connect(path~"/");
incomingBridgeList[path] = incomingBridge;