Don't click here unless you want to be banned.

LSL Wiki : LibraryProductUpdateServer2

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl423.us.archive.org

Product Update Server 2 - works with multiple products


This is enhanced version of the Product Update Server originally written by CometAero and corrected by CryasTokhes, kudos.

This version has script that polls the emails and then passes that through linked message to other scripts, each responsible for one product.
So for each product create a new Product Server script (see below) with all the details specific to that product.

The client script hasn't changed so this will work with original version of Comet's script.
Of course you can modify the client script to poll the server key from text file on a web server - which would make it more robust but requires that you have a web hosting somewhere.

-- KriAyakashi

Email Server
//====================================================================================================
//===Subject Format: password|product|version=========================================================
//===Message Format: UserKey==========================================================================
//==========================================WARNING===================================================
//===========There MUSNT be any spaces in between the "|" and all of them MUST match EXACTLY!!========
//====================================================================================================

default {
    state_entry() {
        llSetTimerEvent(2.5);//Poll for emails.
        llSetObjectDesc((string)llGetKey());//You will need the key when setting up you client
        llWhisper(0, (string)llGetKey());
    }
    
    timer() {
        llGetNextEmail("","");
        if(llGetFreeMemory() < 100){
            llInstantMessage(llGetOwner(), "/me is running low on available memory, script is resetting in 5 seconds.");
            llSleep(5);//There is nothing really to store in the runtime, so if were running
            //low on memory, just notify the owner and reset.
            llResetScript();
        }
    }
    
    email(string time, string address, string subj, string message, integer num_left) {
        key inputUser = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
        llMessageLinked(LINK_SET, num_left, subj, inputUser);
    }
}

Product Server
//Comet Aero
//12-11-06
//Reviewed and updated to compile by: Cryas Tokhes (19.06.07)
//Converted to use link_message by Kri Ayakashi (28.12.07)
//This script is under the protection of the
//DNSOIWKY License
//A.K.A. The "Do Not Sell Or I Will Kill You" License*
string productGiveName = "gGadget 1.1";//Object name inside of the object to give if it is out of date.
string password = "password";//Password to protect from people stealing your hard work!!
string product = "gGadget";//The product series name, this is in place so you can handle multiple products per prim ^.^
integer latestVersion = 1;//This is the latest version of your product.

integer updateNotify = FALSE;//Want the server to email you when a product has been updated?
integer sendOldMessage = FALSE;//Want the server to message user that their product is out of date.
integer sendCurrentMessage = FALSE;//Want the server to message user stating that their product is up to date.
integer sendNewMessage = TRUE;//Want the server to message user that THEY have a newer product version then the server.
integer sendNewProduct = FALSE;//Want the server to RECEIVE the newer product from the user.
string emailAddress = "name@isp.com";//Your email address.

string currentMessage = "Your product is up to date.";
string overMessage = "Your product is newer then what is currently available. Sending to server...";
string oldMessage = "Your product is out of date. Sending new version...";
//====================================================================================================
//===Subject Format: password|product|version=========================================================
//===Message Format: UserKey==========================================================================
//==========================================WARNING===================================================
//===========There MUSNT be any spaces in between the "|" and all of them MUST match EXACTLY!!========
//====================================================================================================

default {
    state_entry() {
        llSetTimerEvent(10.0);//Poll for memory
        llWhisper(0, (string)llGetKey());
    }
    
    timer() {
        if(llGetFreeMemory() < 100){
            llInstantMessage(llGetOwner(), "/me is running low on available memory, script is resetting in 5 seconds.");
            llSleep(5);//There is nothing really to store in the runtime, so if were running
            //low on memory, just notify the owner and reset.
            llResetScript();
        }
    }
    
    link_message(integer sender_num, integer num_left, string subj, key inputUser){
        list messageList = llParseString2List(subj, ["|"], []);//Parses the subject into the parts by "|" 
        string inputPassword = llList2String(messageList,0);//Get the first parced part.
        string inputProduct = llList2String(messageList,1);//Get the second parsed part.
        string inputVersionString = llList2String(messageList,2);//Get the THIRD parsed part.
        integer inputVersion = (integer)inputVersionString;//Just thought it would be better if we did it this way :)        
      
        //===========================================================================================
        if(inputPassword == password && inputProduct == product){
            if(inputVersion < latestVersion){//If its older then the newest version...
                if(sendOldMessage) llInstantMessage(inputUser, oldMessage);//If you want to send a message, then do!
                llGiveInventory(inputUser,productGiveName);//Send newest product
                if(updateNotify) llEmail(emailAddress, product + " has been updated.", product + " has been updated.");//Sends YOU a notification.
            }
            else if (inputVersion == latestVersion){//If it is the newest version...
                if(sendCurrentMessage) llInstantMessage(inputUser, currentMessage);//If you want to send a message, then do!
            }
            else if(inputVersion > latestVersion){//If its NEWER then the newest versiion..............
                if(sendNewMessage) llInstantMessage(inputUser, overMessage);//If you want to send a message, then do.
                if(sendNewProduct) llGiveInventory(inputUser,productGiveName);//If you want to give them YOUR newest version, then do.
            }
        }       
    }
}
//*Comet Aero does not support the killing of Kittens, humans or goldfish.

Client
//Comet Aero
//12-11-06
//Reviewed and updated to compile by: Cryas Tokhes (19.06.07)
//This script is under the protection of the
//DNSOIWKY License
//A.K.A. The "Do Not Sell Or I Will Kill You" License*
//
//==========================================WARNING===================================================
//=======The password, productName and serverKey MUST match EXACTLY=======================================
string serverKey = "1b685a6d-fec9-4f2a-9c3f-53be0ae25164";//What the server whispers when you put the script in the server or reset it.
string productName = "gGadget";//The product name you set in your script.
string password = "password";//The password you set in your server.
integer currentVersion = 1;//The current version of the product.

default {
    on_rez(integer param){
    llEmail(serverKey + "@lsl.secondlife.com", password + "|" + productName + "|" + (string)currentVersion, (string)llGetOwner());
    //Send the server the request.
    llSay(0, "Thank you," + llKey2Name(llGetOwner()) + ", we are currently checking to see if there is a product update available.");
    }
}
//Comet Aero does not support the killing of Kittens, humans or goldfish.
Comments [Hide comments/form]
Attach a comment to this page: