Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Updater Open_Product_Updater  

Open_Product_Updater

Server Script. Please remember to configure the UUID in both the server and the client,it is simple, and free. This prim needs to be in-world at all times. Add any new gadgets to this prim and give them a name such as "Name-V2", where the number is higher that what is already out there.

Category: Updater
By : Ferd Frederix
Created: 2013-05-24 Edited: 2013-05-24
Worlds: Second Life

the Zip file

Download all files for Open_Product_Updater
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Open_Product_Updater_1.lsl
Get file # 2. Open_Product_Updater_2.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // Script by Ferd Frederix
2 // fred@mitsi.com
3 // License: CC-BY-NC
4 // This means you must leave the headers in this script intact, and it is not to be sold by itself, not even for a Linden
5 // You are allowed to use and sell Products that use this script.
6
7 //
8 // Open Update server
9 // Rev 0.1
10 // 5/24/2013
11 // Put Products in a box inside the prim that has this script. Put the Product Updater scipt in products that get rezzed, and not the box that holds them.
12 // You must make the name of the box that you put in this server "Name-VN", where N is a version number such as 1, 1.0, 2 and so on.
13 // The Name must not have a | in it.
14 // The box MUST have a name followed by -V and a version number
15 //
16 // Examples: Horsie-V1.0 ( Same as V1 )
17 // Horsie-V1 ( Same as V1.0, V1.000 etc. )
18 // Horsie-V1.1 ( his will be sent if the product is named Horsie-V0.99999 or lower )
19 // Horsie-V4.1.1 ( This is an illegal number as it has 2 decimals, and will not update as you expect)
20 // Horsie|From Me-V4.1 ( This is an illegal name as it has a "|" in it)
21
22
23
24 //////////////////////////////////////////////////////////
25 // IMPORTANT CONFIGURATION //
26 //////////////////////////////////////////////////////////
27
28 // You MUST put in a UUID from this web site here and put the same UUID in the updater script in your products
29 // Get one from Latif Khalifa at
30 // http://gridurl.appspot.com/random
31 //
32 string UUID = "8c1a45eb-6c4e-4916-8fb7-3252964163d3"; // You MUST change this here and in the products upadter script that you put in your products.
33
34 // Debugging and setup things that can be changed
35 integer debug = FALSE; // Show what is happening in chat
36 integer ENABLED = TRUE; // If TRUE, issue updates to clients, if FALSE, do everything but actually give inventory
37 float HoverText = 1.0; // Set to 0.0 to turn hovertext status updates off
38
39
40 //////////////////////////////////////////////////////////
41 // CODE BEGINS, Move on, nothing here to change //
42 //////////////////////////////////////////////////////////
43
44
45 // global vars
46 integer nServed; // how many updates sent, starts at zero
47
48 // HTTP-IN and other web traffic stuff
49 key URLReq = NULL_KEY;
50 string url; // sop we can release HTTP-In keys
51 key urlRequestId; // the key of the request for a HTTP-In URL
52 key http_RequestID; // the key of th4e Post to outselves
53 integer CHECKTIMER = 600; // run a self-test every 5 minutes. if this fails, request a new URL
54
55
56 RequestHTTPInURL()
57 {
58 llSetTimerEvent(0); // Do not run diags unless we have a valid URL
59 llReleaseURL(url); // there is a limit to the number of URLS, so we always release them.
60 url = "";
61 urlRequestId = llRequestURL(); // get a HTTP-In URL
62 }
63
64
65 DEBUG(string msg)
66 {
67 if(debug)
68 llOwnerSay(llGetScriptName() + " : " + msg);
69 }
70
71 key Request(string URL)
72 {
73 llSetText("Registering",<0,0,1>,HoverText); // blue
74 string url = "http://gridurl.appspot.com/reg?service=" + UUID + "&url=" + llEscapeURL(URL) + "/";
75 return llHTTPRequest( url, [HTTP_METHOD, "GET"], "");
76 }
77
78
79 default
80 {
81 // When rezzed, lets start everything from scratch
82 on_rez(integer param)
83 {
85 }
86
87 // when reset, we get a HTTP-IN URL. Without this, we can do nothing
89 {
90 llSetText("Initializing",<0,0,1>,HoverText); // blue
91 RequestHTTPInURL();
92 }
93
94 // This event will occur whenever a URL is granted or the web server it created gets a POST or GET
95 http_request(key id, string method, string body)
96 {
97 if(method == URL_REQUEST_GRANTED)
98 {
99 DEBUG(body);
100 url = body; // save body response, which is our actual URL, so we can release it.
101 llSetText("Update Server is Starting",<0,0,1>,HoverText);
102 URLReq = Request(body); // send it to the server so the gadgets in the field know where to go to get updates.
103
104 llSetTimerEvent(2); // check server just to be certain
105 }
106 else if(method == URL_REQUEST_DENIED)
107 {
108 llSetText("ERROR: URL request was denied, retrying in 1 minute",<1,0,0>,HoverText);
109 llSleep(60);
110 RequestHTTPInURL();
111 }
112 else if(id == URLReq)
113 {
114 if(body == "OK")
115 {
116 llSetText("Test passed ",<0,0,1>,HoverText);
117 llSleep(1);
118 }
119 else
120 {
121 llSetText("Unable to register, please check your UUID",<1,0,0>,HoverText);
122 }
123 }
124 else if(method == "GET")
125 {
126 DEBUG("GET ACK");
127 llHTTPResponse(id, 200, "ACK");
128 }
129 else if(method == "POST")
130 {
131 DEBUG("POST received");
132 string resp = llGetHTTPHeader(id, "x-query-string");
133 // Product Name|Ver|UUID|Avatar Name is the message
134
135 // string remainder = llDeleteSubString(body, 0, llSubStringIndex(body, "\n\n")+1) ;
136 DEBUG("Query String = " + resp);
137
138
139 list info = llParseString2List(resp,["|"],[]);
140 DEBUG(llDumpList2String(info,"|"));
141
142 // get rid of the q= at the beginning of the name
143 string name= llList2String(info,0);
144 list names = llParseString2List(name,["="],[]);
145
146 string shortName = llList2String(names,1);
147 DEBUG("shortName:" + shortName);
148 names = llParseString2List(shortName,["-V"],["-V"]);
149
150 float VerWanted = (float) llList2String(names,1);
151 DEBUG("Version of product:" + (string) VerWanted);
152
153 string productName = llList2String(names,0);
154 DEBUG("productName:" + productName);
155
156 key Theirkey = (key) llList2String(info,1);
157 DEBUG("Owner key:" + (string) Theirkey);
158
159 string Avatar = llList2String(info,2);
160
161 // should look like this for a version 1 Object
162 // Object-1|1.0|10000000-0000-0000-0000-000000000000|SecondLife OwnerName
163
165 while(count--)
166 {
167 string fullname = llGetInventoryName(INVENTORY_OBJECT,count); // obj 1 = 0
168 list parts = llParseString2List(fullname,["-V"],["-V"]);
169
170 string invName = llList2String(parts,0);
171 float invVersion = (float) llList2String(parts,1);
172 DEBUG("Inv Name :" + (string) invName);
173 DEBUG("Inv Version:" + (string) invVersion);
174
175 if(productName == invName && invVersion > VerWanted )
176 {
177 DEBUG("Giving:" + invName);
178 nServed++; // counter for products dispensed
179 if(ENABLED) llGiveInventory(Theirkey,fullname);
180 llSetText(Avatar + " got " + fullname + "\nTotal Items Updated:" + (string) nServed, <1,1,1>,1.0 );
181 }
182 }
183 llHTTPResponse(id, 200, "ACK");
184 }
185 else
186 {
187 llSetText("Unknown command received",<1,0,0>,HoverText);
188 llHTTPResponse(id, 501, "Not Implemented "+method);
189 }
190 }
191
192 // This even will run when a web page is fetched
193 http_response(key request_id, integer status, list metadata, string body)
194 {
195
196 // This would be the response from Grispot that out URL was accepted.
197 if(URLReq == request_id)
198 {
199 URLReq = NULL_KEY;
200 if(status == 200)
201 {
202 llSetText("Server is OK",<0,1,0>,HoverText);
203 }
204 else
205 {
206 llSetText("The internet is broken - retrying",<1,0,0>,HoverText);
207 llSleep(60); // be nice
208 RequestHTTPInURL(); // try again
209 }
210 }
211
212 // this occurs when we test ourselves. We should have gotten an ACK to keep us happy.
213 // if no ACK, we need a new URL
214 else if(request_id == http_RequestID)
215 {
216 if(body != "ACK")
217 {
218 llSetText("The internet is broken - retrying",<1,0,0>,HoverText);
219 llSleep(60); // be nice to ourserver, the server has probably run out of URLS.
220 RequestHTTPInURL();
221 }
222 else
223 {
224 llSetText("Server is ready",<0,1,0>,HoverText);
225 }
226 }
227 }
228
229
230 // run a self test every so often by GETing from ourselves
231 // This also resets the timer to CHECKTIMER, as the very first one of these happens at startup in a few seconds.
232 timer()
233 {
234 llSetText("Update Server is checking itself",<0,0,1>,HoverText);
235 http_RequestID = llHTTPRequest(url,[HTTP_METHOD,"GET"],"");
236 llSetTimerEvent(CHECKTIMER); // check server just to be certain
237 }
238
239
240
241 }

Open_Product_Updater

Client Script. Please remember to configure the UUID in both the server and the client,it is simple, and free. Make sure your product is named something like "Name-V1", where the number is the latest version. Give this out. When it is rezzed, it will check with the server to see if there is a higher numbered object available.

You can set CHATTY = FALSE and the operation of the updater will be silent. If TRUE, it will announce "Checking for updates" when it is rezzed.

Category: Updater
By : Ferd Frederix
Created: 2013-05-24 Edited: 2013-05-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // Script by Ferd Frederix
2 // fred@mitsi.com
3 // License: CC-BY-NC
4 // This means you must leave the headers in this script intact, and it is not to be sold by itself, not even for a Linden
5 // You are allowed to use and sell Products that use this script.
6
7 //
8 // Open Update Client
9 // Updater that goes into any product.
10 // Rev 1.0
11 // 5/24/2013
12
13 // Put this script into any prim and give the prim to someone.
14 // When that product is rezzed, it will check for updates from a Server prim
15 // You must make the name of the Prim "Name-VN", where N is a version number such as 1, 1.0, 2 and so on.
16 // The Name must not have a | in it.
17 // The product MUST have a name followed by -V and a version number
18 //
19 // Examples: Horsie-V1.0 ( Same as V1)
20 // Horsie-V1 ( Same as V1.0)
21 // Horsie-V1.1 ( if inside the updater, this will be sent if the version of Horsie is less than 1.1 )
22 // Horsie-V4.1.1 ( This is an illegal number as it has 2 decimals, and will not update as you expect)
23 // Horsie|From Me-V4.1 ( This is an illegal name as it has a "|" in it)
24
25 //////////////////////////////////////////////////////////
26 // IMPORTANT CONFIGURATION //
27 //////////////////////////////////////////////////////////
28
29 // You MUST put in a UUID from this web site here and put the same UUID in the updater script
30 // Get a UUID from Latif Khalifa at:
31 //
32 // http://gridurl.appspot.com/random
33 //
34 // You only need to do this once for the server that has the same key. That server has to have a copy of the object in it.
35 // You can run more than one server, just make sure that the product goes into the correct server and that the key inside this script in that product matches the key inside the server
36
37 string UUID = "8c1a45eb-6c4e-4916-8fb7-3252964163d3"; // You MUST change this
38
39 integer CHATTY = TRUE; // When TRUE, tells the prim owner it is checking for updates. If FALSE, this script is silent.
40
41 //////////////////////////////////////////////////////////
42 // CODE BEGINS, Move on, nothing here to change //
43 //////////////////////////////////////////////////////////
44
45
46 // Just for Debugging
47 integer debug = FALSE; // Show what is happenning in chat if TRUE
48
49 DEBUG(string msg)
50 {
51 if(debug)
52 llOwnerSay(llGetScriptName() + " : " + msg);
53 }
54
55
56 // globals
57 key http_request_id; // this key of for the update request
58 key URL_request_id; // this key is for the HTTP-In
59 string serverURL; // This will become out HTTP-I URL
60
61
62 key Request(string cmd)
63 {
64 DEBUG("Sending:"+serverURL+"?"+cmd);
65 return llHTTPRequest( serverURL+"?"+cmd, [HTTP_METHOD, "GET"], "");
66 }
67
68
69
70 CheckForUpdate()
71 {
72 // Check for an update from the server prim
73 string AvatarName = llKey2Name(llGetOwner());
74 string AvatarNameESC = llEscapeURL(AvatarName);
75 string ProductName = llEscapeURL(llGetObjectName());
76
77 //Product Name|UUID|Avatar Name is the message
78
79 string query = "?q=" + ProductName + "|"+ (string) llGetOwner() +"|" + AvatarName;
80
81 DEBUG("URL:" + serverURL);
82 http_request_id = llHTTPRequest(serverURL + query,[HTTP_METHOD,"POST"],"");
83 }
84
85
86 default
87 {
88
89 on_rez(integer param)
90 {
92 }
93
95 {
96 if(CHATTY)
97 llOwnerSay( "Checking for updates");
98 string keyURL = "http://gridurl.appspot.com/get/"+ llEscapeURL(UUID);
99 DEBUG(keyURL);
100 URL_request_id = llHTTPRequest(keyURL, [HTTP_METHOD, "GET"], ""); // find the server
101 }
102
103
104 http_response(key request_id, integer status, list metadata, string body)
105 {
106 if(URL_request_id == request_id)
107 {
108 URL_request_id = NULL_KEY; // the same event sometimes shows up more then once
109 if(status == 200)
110 {
111 DEBUG("Server URL is :" + body);
112 serverURL = body;
113 CheckForUpdate(); // let's see if there is an update by connecting to the URL we just got
114 }
115 }
116 else if(http_request_id == request_id)
117 {
118 if(status == 200)
119 {
120 DEBUG("Success response:" + body); // report what was returned from update request
121 }
122 else
123 {
124 DEBUG("Fail response:" + body); // report what was returned from update request
125 }
126 }
127 }
128 }

Back to the Best Free Tools in Second Life and OpenSim.