Welcome Guest! To enable all features please try to register or login.
Options
View
Go to last post Go to first unread
Cactusthorn  
#1 Posted : Saturday, August 15, 2015 3:43:21 AM(UTC)
Cactusthorn

Rank: Member

Reputation:

Groups: Registered
Joined: 8/10/2015(UTC)
Posts: 11

Was thanked: 1 time(s) in 1 post(s)
Hi,
As i was trying find a rapid way of restarting a game, I came a cross the foiling problem.

If after the initial connection, you close the connection with GameConnection.Close() method and then try to reconnect again with GameConnection.Open(), you will get two unhandled exeptions:
14:24:03.031 I AIService.Stop: Stopping AI service.
14:24:03.067 I AIService.EndGame: Game ended. Terminating tanks and cleaning up.
14:24:03.067 I AIService.TerminateTank: Terminating tank MapperTank (ID *********************************************, User Cactusthorn).
14:24:03.113 I AIService.Stop: AI service stopped.
14:24:18.116 I GameConnection.Open: Game connection initialized, process command was: ...TankAIRunner.exe"
14:24:18.116 I AIService.Start: Starting AI service on port 8000.
14:24:18.129 E ServiceManager.CurrentDomain_UnhandledException: Object reference not set to an instance of an object.
14:24:18.131 E GameConnection.CurrentDomain_UnhandledException: Unhandled Exception:
Object reference not set to an instance of an object.

I simply replaced the loop waiting for the user to press the ESC key in the main method by this one the get the error:
Code:

do
{
    key = Console.ReadKey(true).Key;
    if (key == ConsoleKey.R)
    {
        GameConnection.Close();
        Console.WriteLine("Connection Terminated.");

        System.Threading.Thread.Sleep(15000);

        GameConnection.Open();
        Console.WriteLine("Reconnection sucessfull.");
    }
} while (key != ConsoleKey.Escape);

VictorTrax  
#2 Posted : Saturday, August 15, 2015 5:32:26 AM(UTC)
VictorTrax

Rank: Administration

Reputation:

Groups: Administrators, Registered
Joined: 5/7/2015(UTC)
Posts: 42

Thanks: 2 times
Was thanked: 5 time(s) in 4 post(s)
As of now the API doesn't support re-opening a connection after calling Close, so Close is in effect "final". Granted you should get a better error message; I think that scenario just wasn't covered in testing. However, the idea of being able to terminating tanks and recycling the connection, without restarting the AI program, would be convenient, so we may try to support that in an API update soon.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.

Notification

Icon
Error