I have Array list, and in this array have 4 url and port, i want when user connect from index[0] then connection lose i show button when click user this button i want to connect same port but second url like index[1].
How i solve and how can i do please help thanks. This is my List
private static var urisToTry:Array = [
new SocketUri("123.net", 123),
new SocketUri("1234.net", 123),
new SocketUri("123.net", 321),
new SocketUri("1234.net", 321)
];
Any help would be great i need pseudo code
Something like this:
// current array index
private var connIndex:int = 0;
public function connect():void
{
var mySocketURI:SocketUri = urisToTry[connIndex];
// do your connection here
}
private function onConnectionLost():void
{
// increase index and check if it is within array length
if(connIndex >= urisToTry.length -1)
connIndex = 0;
else
connIndex++;
connect();
}