diff options
Diffstat (limited to 'OpenSim/Tools/pCampBot')
-rw-r--r-- | OpenSim/Tools/pCampBot/PhysicsBot.cs | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 2070bfd..945697b 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs | |||
@@ -62,7 +62,11 @@ namespace pCampBot | |||
62 | public event AnEvent OnConnected; | 62 | public event AnEvent OnConnected; |
63 | public event AnEvent OnDisconnected; | 63 | public event AnEvent OnDisconnected; |
64 | 64 | ||
65 | protected Timer m_action; // Action Timer | 65 | /// <summary> |
66 | /// Keep a track of the continuously acting thread so that we can abort it. | ||
67 | /// </summary> | ||
68 | private Thread m_actionThread; | ||
69 | |||
66 | protected List<uint> objectIDs = new List<uint>(); | 70 | protected List<uint> objectIDs = new List<uint>(); |
67 | 71 | ||
68 | protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here | 72 | protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here |
@@ -98,8 +102,7 @@ namespace pCampBot | |||
98 | 102 | ||
99 | //We do our actions here. This is where one would | 103 | //We do our actions here. This is where one would |
100 | //add additional steps and/or things the bot should do | 104 | //add additional steps and/or things the bot should do |
101 | 105 | private void Action() | |
102 | void m_action_Elapsed(object sender, ElapsedEventArgs e) | ||
103 | { | 106 | { |
104 | while (true) | 107 | while (true) |
105 | { | 108 | { |
@@ -145,6 +148,9 @@ namespace pCampBot | |||
145 | /// </summary> | 148 | /// </summary> |
146 | public void shutdown() | 149 | public void shutdown() |
147 | { | 150 | { |
151 | if (m_actionThread != null) | ||
152 | m_actionThread.Abort(); | ||
153 | |||
148 | client.Network.Logout(); | 154 | client.Network.Logout(); |
149 | } | 155 | } |
150 | 156 | ||
@@ -177,11 +183,10 @@ namespace pCampBot | |||
177 | { | 183 | { |
178 | if (OnConnected != null) | 184 | if (OnConnected != null) |
179 | { | 185 | { |
180 | m_action = new Timer(somthing.Next(1000, 10000)); | 186 | Thread.Sleep(somthing.Next(1000, 10000)); |
181 | m_action.Enabled = true; | 187 | m_actionThread = new Thread(Action); |
182 | m_action.AutoReset = false; | 188 | m_actionThread.Start(); |
183 | m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed); | 189 | |
184 | m_action.Start(); | ||
185 | // OnConnected(this, EventType.CONNECTED); | 190 | // OnConnected(this, EventType.CONNECTED); |
186 | if (wear == "save") | 191 | if (wear == "save") |
187 | { | 192 | { |
@@ -386,6 +391,13 @@ namespace pCampBot | |||
386 | public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) | 391 | public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) |
387 | { | 392 | { |
388 | // m_log.ErrorFormat("Fired Network_OnDisconnected"); | 393 | // m_log.ErrorFormat("Fired Network_OnDisconnected"); |
394 | |||
395 | // Only pass on the disconnect message when we receive a SimShutdown type shutdown. We have to ignore | ||
396 | // the earlier ClientInitiated shutdown callback. | ||
397 | // if ( | ||
398 | // (args.Reason == NetworkManager.DisconnectType.SimShutdown | ||
399 | // || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) | ||
400 | // && OnDisconnected != null) | ||
389 | if (OnDisconnected != null) | 401 | if (OnDisconnected != null) |
390 | { | 402 | { |
391 | OnDisconnected(this, EventType.DISCONNECTED); | 403 | OnDisconnected(this, EventType.DISCONNECTED); |