Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 Before February 2015

Tako
Member
From: Memphis, Tennessee, USA
Joined: 2015-08-10
Posts: 6,663
Website

How to disconnect properly? [C#] [Bot related]

I'm having trouble disconnecting properly.

"myConnection.Disconnect();" successfully disconnects the bot, but you continue to see the ghost of the bot until you refresh the page.

I know this can be fixed somehow, because once you close the program entirely, the ghost goes away. However, I don't want to have to close the program every time I want it to disconnect.

The code:

               public static Connection Conn;          static string GameID = "everybody-edits-su9rn58o40itdbnw69plyw";         static string GameVersion = "Everybodyedits145";          public static string Name;         public static string Pass;         public static string Room;          public static void Connect()         {             try             {                 Client client = PlayerIO.QuickConnect.SimpleConnect(GameID, Name, Pass);                  Conn = client.Multiplayer.CreateJoinRoom(Room, GameVersion, true, new Dictionary<string, string>(), new Dictionary<string, string>());                    Conn.OnMessage += onMessage;                 Conn.Send("init");                 Conn.Send("init2");             }              catch (PlayerIOError e)             { Convert.ToString(e.Source); }         }

The connection is controlled by a Thread:
           public static Thread Run = new Thread (new ThreadStart(Connect));
           Run.Start();

And terminated by:
           Conn.Disconnect();
           Run.Abort();

Any help?


Yeah, well, you know that's just like, uh, your opinion, man.

Offline

#2 Before February 2015

Krock
Guest

Re: How to disconnect properly? [C#] [Bot related]

A thread runns asynchronous as the others and your bot, I take on you use console, closes after finnishing the commands.
= the console is done before the thread and closes, but the thread still runns = ghosted bot

EDIT: eeversion is 147 and you can declare multiple variables with:

public static int variable00, variable01, variable02;

Last edited by Krock (Jan 6 2013 1:59:47 pm)

#3 Before February 2015

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: How to disconnect properly? [C#] [Bot related]

Well, I don't have the "ghost" that you're talking about.
A simple Connection.Disconnect() works for me.

Oh, and sometimes I
Connection = null;
Not sure why. Just do.

Offline

#4 Before February 2015

Tako
Member
From: Memphis, Tennessee, USA
Joined: 2015-08-10
Posts: 6,663
Website

Re: How to disconnect properly? [C#] [Bot related]

Krock wrote:

A thread runns asynchronous as the others and your bot, I take on you use console, closes after finnishing the commands.
= the console is done before the thread and closes, but the thread still runns = ghosted bot

Thanks a bunch.

I actually just replaced the thread with a single call to Connect() and it worked out. //forums.everybodyedits.com/img/smilies/tongue

I'm sure the outdated version didn't help either.


Yeah, well, you know that's just like, uh, your opinion, man.

Offline

Tako1423509073452359

Board footer

Powered by FluxBB

[ Started around 1732474828.5024 - Generated in 0.046 seconds, 12 queries executed - Memory usage: 1.4 MiB (Peak: 1.51 MiB) ]