| Home Page | Recent Changes

LibHTTP/NewsFeed

class mutNewsFeed extends mutator;

var HttpSock hs;
var NewsFeed nf;

event prebeginplay()
{
    hs = spawn(class'LibHTTP.HttpSock');
    hs.OnComplete = DownloadCompleted;
    hs.OnError = DownloadError;
    nf = new class'LibHTTP.NewsFeed';
    Log("------ NewsFeed loaded --------");
}

function Mutate(string MutateString, PlayerController Sender)
{
    local array<string> mut;
    Super.Mutate(MutateString, Sender);
    Split(MutateString, " ", mut);
    if (mut[0] ~= "rdf")
    {
        if (mut[1] ~= "fetch")
        {
            if (Caps(nf.Source) != Caps(mut[2]))
            {
                nf.Source = mut[2];
                hs.HttpRequest(nf.Source);
                Level.Game.BroadcastHandler.BroadcastText(none, Sender, "RDF> Retreiving news ...");
            }
            else Log("RDF> News from"@nf.ChannelTitle@"available");
        }
        else {
            if (int(mut[1]) < nf.Entries.length)
                Level.Game.BroadcastHandler.BroadcastText(none, Sender, "NEWS>"@nf.ChannelTitle@" - "@nf.Entries[int(mut[1])].Title);
                else Level.Game.BroadcastHandler.BroadcastText(none, Sender, "RDF> Only"@nf.Entries.length@"news items available");
        }
    }
}

function DownloadCompleted()
{
    if (hs.LastStatus == 200)
    {
        nf.LastUpdate = hs.now();
        nf.ParseRDFData(hs.ReturnData);
        if (nf.Entries.length > 0) Level.Game.BroadcastHandler.Broadcast(self, "RDF> News from"@nf.ChannelTitle@"available");
    }
}

function OnError(string ErrorMessage, optional string Param1, optional string Param2)
{
    Level.Game.BroadcastHandler.Broadcast(self, "RDF> Download error:"@ErrorMessage@Param1@Param2);
}

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In