aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot/Bot.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-08-19 23:50:18 +0100
committerJustin Clark-Casey (justincc)2013-08-19 23:50:18 +0100
commit589b1a2eaf9058c3577b17ae76580a79ba855978 (patch)
treec0f9119ce19932e5b0651e66b0daee1d9479bb1b /OpenSim/Tools/pCampBot/Bot.cs
parentrefactor: start bot connection thread within BotManager rather than externally (diff)
downloadopensim-SC_OLD-589b1a2eaf9058c3577b17ae76580a79ba855978.zip
opensim-SC_OLD-589b1a2eaf9058c3577b17ae76580a79ba855978.tar.gz
opensim-SC_OLD-589b1a2eaf9058c3577b17ae76580a79ba855978.tar.bz2
opensim-SC_OLD-589b1a2eaf9058c3577b17ae76580a79ba855978.tar.xz
Make it possible to reconnect pCampbots with the console command "connect [<n>]".
If no n is given then all available bots are connected
Diffstat (limited to '')
-rw-r--r--OpenSim/Tools/pCampBot/Bot.cs96
1 files changed, 71 insertions, 25 deletions
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index be7a5a1..f7af26e 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -158,8 +158,6 @@ namespace pCampBot
158 158
159 behaviours.ForEach(b => b.Initialize(this)); 159 behaviours.ForEach(b => b.Initialize(this));
160 160
161 Client = new GridClient();
162
163 Random = new Random(Environment.TickCount);// We do stuff randomly here 161 Random = new Random(Environment.TickCount);// We do stuff randomly here
164 FirstName = firstName; 162 FirstName = firstName;
165 LastName = lastName; 163 LastName = lastName;
@@ -170,6 +168,59 @@ namespace pCampBot
170 168
171 Manager = bm; 169 Manager = bm;
172 Behaviours = behaviours; 170 Behaviours = behaviours;
171
172 // Only calling for use as a template.
173 CreateLibOmvClient();
174 }
175
176 private void CreateLibOmvClient()
177 {
178 GridClient newClient = new GridClient();
179
180 if (Client != null)
181 {
182 newClient.Settings.LOGIN_SERVER = Client.Settings.LOGIN_SERVER;
183 newClient.Settings.ALWAYS_DECODE_OBJECTS = Client.Settings.ALWAYS_DECODE_OBJECTS;
184 newClient.Settings.AVATAR_TRACKING = Client.Settings.AVATAR_TRACKING;
185 newClient.Settings.OBJECT_TRACKING = Client.Settings.OBJECT_TRACKING;
186 newClient.Settings.SEND_AGENT_THROTTLE = Client.Settings.SEND_AGENT_THROTTLE;
187 newClient.Settings.SEND_AGENT_UPDATES = Client.Settings.SEND_AGENT_UPDATES;
188 newClient.Settings.SEND_PINGS = Client.Settings.SEND_PINGS;
189 newClient.Settings.STORE_LAND_PATCHES = Client.Settings.STORE_LAND_PATCHES;
190 newClient.Settings.USE_ASSET_CACHE = Client.Settings.USE_ASSET_CACHE;
191 newClient.Settings.MULTIPLE_SIMS = Client.Settings.MULTIPLE_SIMS;
192 newClient.Throttle.Asset = Client.Throttle.Asset;
193 newClient.Throttle.Land = Client.Throttle.Land;
194 newClient.Throttle.Task = Client.Throttle.Task;
195 newClient.Throttle.Texture = Client.Throttle.Texture;
196 newClient.Throttle.Wind = Client.Throttle.Wind;
197 newClient.Throttle.Total = Client.Throttle.Total;
198 }
199 else
200 {
201 newClient.Settings.LOGIN_SERVER = LoginUri;
202 newClient.Settings.ALWAYS_DECODE_OBJECTS = false;
203 newClient.Settings.AVATAR_TRACKING = false;
204 newClient.Settings.OBJECT_TRACKING = false;
205 newClient.Settings.SEND_AGENT_THROTTLE = true;
206 newClient.Settings.SEND_PINGS = true;
207 newClient.Settings.STORE_LAND_PATCHES = false;
208 newClient.Settings.USE_ASSET_CACHE = false;
209 newClient.Settings.MULTIPLE_SIMS = true;
210 newClient.Throttle.Asset = 100000;
211 newClient.Throttle.Land = 100000;
212 newClient.Throttle.Task = 100000;
213 newClient.Throttle.Texture = 100000;
214 newClient.Throttle.Wind = 100000;
215 newClient.Throttle.Total = 400000;
216 }
217
218 newClient.Network.LoginProgress += this.Network_LoginProgress;
219 newClient.Network.SimConnected += this.Network_SimConnected;
220 newClient.Network.Disconnected += this.Network_OnDisconnected;
221 newClient.Objects.ObjectUpdate += Objects_NewPrim;
222
223 Client = newClient;
173 } 224 }
174 225
175 //We do our actions here. This is where one would 226 //We do our actions here. This is where one would
@@ -192,7 +243,7 @@ namespace pCampBot
192 /// <summary> 243 /// <summary>
193 /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes. 244 /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes.
194 /// </summary> 245 /// </summary>
195 public void shutdown() 246 public void Disconnect()
196 { 247 {
197 ConnectionState = ConnectionState.Disconnecting; 248 ConnectionState = ConnectionState.Disconnecting;
198 249
@@ -202,34 +253,27 @@ namespace pCampBot
202 Client.Network.Logout(); 253 Client.Network.Logout();
203 } 254 }
204 255
256 public void Connect()
257 {
258 Thread connectThread = new Thread(ConnectInternal);
259 connectThread.Name = Name;
260 connectThread.IsBackground = true;
261
262 connectThread.Start();
263 }
264
205 /// <summary> 265 /// <summary>
206 /// This is the bot startup loop. 266 /// This is the bot startup loop.
207 /// </summary> 267 /// </summary>
208 public void startup() 268 private void ConnectInternal()
209 { 269 {
210 Client.Settings.LOGIN_SERVER = LoginUri;
211 Client.Settings.ALWAYS_DECODE_OBJECTS = false;
212 Client.Settings.AVATAR_TRACKING = false;
213 Client.Settings.OBJECT_TRACKING = false;
214 Client.Settings.SEND_AGENT_THROTTLE = true;
215 Client.Settings.SEND_AGENT_UPDATES = false;
216 Client.Settings.SEND_PINGS = true;
217 Client.Settings.STORE_LAND_PATCHES = false;
218 Client.Settings.USE_ASSET_CACHE = false;
219 Client.Settings.MULTIPLE_SIMS = true;
220 Client.Throttle.Asset = 100000;
221 Client.Throttle.Land = 100000;
222 Client.Throttle.Task = 100000;
223 Client.Throttle.Texture = 100000;
224 Client.Throttle.Wind = 100000;
225 Client.Throttle.Total = 400000;
226 Client.Network.LoginProgress += this.Network_LoginProgress;
227 Client.Network.SimConnected += this.Network_SimConnected;
228 Client.Network.Disconnected += this.Network_OnDisconnected;
229 Client.Objects.ObjectUpdate += Objects_NewPrim;
230
231 ConnectionState = ConnectionState.Connecting; 270 ConnectionState = ConnectionState.Connecting;
232 271
272 // Current create a new client on each connect. libomv doesn't seem to process new sim
273 // information (e.g. EstablishAgentCommunication events) if connecting after a disceonnect with the same
274 // client
275 CreateLibOmvClient();
276
233 if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", StartLocation, "Your name")) 277 if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", StartLocation, "Your name"))
234 { 278 {
235 ConnectionState = ConnectionState.Connected; 279 ConnectionState = ConnectionState.Connected;
@@ -474,6 +518,8 @@ namespace pCampBot
474// || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) 518// || args.Reason == NetworkManager.DisconnectType.NetworkTimeout)
475// && OnDisconnected != null) 519// && OnDisconnected != null)
476 520
521
522
477 if ( 523 if (
478 (args.Reason == NetworkManager.DisconnectType.ClientInitiated 524 (args.Reason == NetworkManager.DisconnectType.ClientInitiated
479 || args.Reason == NetworkManager.DisconnectType.ServerInitiated 525 || args.Reason == NetworkManager.DisconnectType.ServerInitiated