sloodle_multi_url_loader.lslp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. // Sloodle multiple URL loader
  4. // Manages the parallelized loading of multiple (potentially) simultaneous URLs for different users
  5. // (NOTE: requires copies of the "sloodle_parallel_url_loader_x.lsl" script to be in the SAME prim)
  6. // Part of the Sloodle project (www.sloodle.org)
  7. //
  8. // Copyright (c) 2007 Sloodle (various contributors)
  9. // Released under the GNU GPL
  10. //
  11. // Contributors:
  12. // Peter R. Bloomfield
  13. //
  14. //
  15. // When receiving an appropriate link message, this will forward it on an appropriate channel to be handled.
  16. // It will then move on to the next channel, allowing a sequence to be created, whereby URL loading can be parallelized.
  17. // NOTE: you may need to customize the "NUM_PARALLEL_SCRIPTS" value if you have fewer parallel scripts.
  18. ///// DATA /////
  19. // The maximum number of parallel scripts available (should not be bigger than list below)
  20. integer NUM_PARALLEL_SCRIPTS = 10;
  21. // INCOMING link message number for load requests
  22. integer SLOODLE_CHANNEL_OBJECT_LOAD_URL = -1639270041;
  23. // OUTGOING link message numbers for parallel load requests
  24. list SLOODLE_CHANNEL_LIST_LOAD_URL_x = [
  25. -1699000001, //SLOODLE_CHANNEL_LOAD_URL_0
  26. -1699000002, //SLOODLE_CHANNEL_LOAD_URL_1
  27. -1699000003, //SLOODLE_CHANNEL_LOAD_URL_2
  28. -1699000004, //SLOODLE_CHANNEL_LOAD_URL_3
  29. -1699000005, //SLOODLE_CHANNEL_LOAD_URL_4
  30. -1699000006, //SLOODLE_CHANNEL_LOAD_URL_5
  31. -1699000007, //SLOODLE_CHANNEL_LOAD_URL_6
  32. -1699000008, //SLOODLE_CHANNEL_LOAD_URL_7
  33. -1699000009, //SLOODLE_CHANNEL_LOAD_URL_8
  34. -1699000010 //SLOODLE_CHANNEL_LOAD_URL_9
  35. ];
  36. // Current channel being used (corresponds to indices of above list)
  37. integer current_request_channel = 0;
  38. ///// ---- /////
  39. default
  40. {
  41. link_message( integer sender_num, integer msg_num, string str, key id )
  42. {
  43. // Is this the correct message number and are the variables non-empty?
  44. if (msg_num == SLOODLE_CHANNEL_OBJECT_LOAD_URL && str != "" && id != NULL_KEY)
  45. {
  46. // Send the request to a parallel script
  47. llMessageLinked(LINK_THIS, llList2Integer(SLOODLE_CHANNEL_LIST_LOAD_URL_x, current_request_channel), str, id);
  48. current_request_channel += 1;
  49. // Wrap the request channel value round if necessary
  50. integer num = llGetListLength(SLOODLE_CHANNEL_LIST_LOAD_URL_x);
  51. if (NUM_PARALLEL_SCRIPTS < num) num = NUM_PARALLEL_SCRIPTS;
  52. current_request_channel %= num;
  53. }
  54. }
  55. }
  56. // Please leave the following line intact to show where the script lives in Git:
  57. // SLOODLE LSL Script Git Location: assets/misc/sloodle_multi_url_loader.lslp