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

View File

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

View File

@ -123,7 +123,6 @@ namespace EduNetworkBuilder
writer.WriteElementString("linktype", theLinkType.ToString()); writer.WriteElementString("linktype", theLinkType.ToString());
writer.WriteElementString("uniqueidentifier", UniqueIdentifier.ToString()); writer.WriteElementString("uniqueidentifier", UniqueIdentifier.ToString());
writer.WriteEndElement(); writer.WriteEndElement();
} }