Fixed glitch with finding best wireless

This commit is contained in:
Tim Young 2015-08-22 14:23:50 -07:00
parent 5df3735d09
commit 322b14a608
3 changed files with 19 additions and 5 deletions

View File

@ -177,6 +177,8 @@ namespace EduNetworkBuilder
break;
}
}
DoAllVerifyLinks();
DoAllAutoJoin();
}
if (NetMessage.GetText() != "" && !AlreadyDisplayedMessage)
{
@ -1134,7 +1136,7 @@ namespace EduNetworkBuilder
if(answer != null)
{
double tdist = distance(starting, checking);
if(tdist < l_distance)
if(tdist < l_distance && tdist < NB.WirelessMaxUnsuccessfulLink)
{
l_distance = tdist;
found = answer;

View File

@ -676,7 +676,8 @@ namespace EduNetworkBuilder
tryit = false;
if (nic.GetNicType != NicType.wlan) continue;
if (nic.SSID == "") continue;
if (!nic.isConnected(false)) tryit = true;
if (!nic.isConnected(false))
tryit = true;
if(!tryit)
{
//Check distance
@ -692,11 +693,23 @@ namespace EduNetworkBuilder
//Tryit tells us if we should try to reconnect.
if (tryit)
{
if(nic.isConnected(false))
{
//remove old connection
NetworkLink oNL = myNet.GetLinkFromID(nic.ConnectedLink);
if(oNL != null)
{
myNet.RemoveComponent(oNL);
oNL.Destroy();
}
}
//We want to find the closest device with an open wport that matches ssid/key and connect to it.
NetworkCard Closest = myNet.BestWirelessLinkForDevice(nic);
if(Closest != null)
{
NetworkLink newLink = new NetworkLink(nic.myID, Closest.myID, LinkType.wireless);
nic.ConnectedLink = newLink.GetUniqueIdentifier;
Closest.ConnectedLink = newLink.GetUniqueIdentifier;
myNet.AddItem(newLink);
didsomething = true;
}

View File

@ -117,13 +117,12 @@ namespace EduNetworkBuilder
public override void Save(XmlWriter writer)
{
writer.WriteStartElement("link");
SrcNic.Save(writer,"SrcNic");
DstNic.Save(writer,"DstNic");
SrcNic.Save(writer, "SrcNic");
DstNic.Save(writer, "DstNic");
writer.WriteElementString("hostname", hostname);
writer.WriteElementString("linktype", theLinkType.ToString());
writer.WriteElementString("uniqueidentifier", UniqueIdentifier.ToString());
writer.WriteEndElement();
}