RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RUO 2.0] Integrated Web-Server

Vorspire

Knight
You would have to use a different way to process the XML. You could always impliment url-queries into your Status.vor page taht would return only specific data, for example:

Code:
http://<server-ip>/status.vor?get=clients

Which could return:
Code:
<clients>1234</clients>

...and nothing more, unless you were to extend the url-query:
Code:
http://<server-ip>/status.vor?get=clients+address

Which could return:
Code:
<clients>1234</clients>
<address>127.0.0.1</address>

--------------------------

On another note, the Status.vor page comes with 3 modes: xml, html & plain.
You can try to ask or the data in plain-format, which can be more easily seperated with a simple PHP explode function, using a comma , as the separator.
 

Nockar

Sorceror
That makes good since.

I am not really sure what it’s doing this still. But for some reason it always will only return the full XML file. Never part or it.

So when I do this
Code:
<?php
//Initialize the XML parser
$parser=xml_parser_create();

//Function to use at the start of an element
function start($parser,$element_name,$element_attrs)
  {
  switch($element_name)
    {
[B]    case "TOTALS>":
    echo "Totals<br />";
    break;

    case "ACCOUNTS":
    echo "Accounts: ";
    break;

    case "CLIENTS":
    echo "Clients: ";
    break;

    case "ITEMS":
    echo "Items: ";
    break;

    case "MOBILES":
    echo "Mobiles: ";
    }[/B]
  }

//Function to use at the end of an element
function stop($parser,$element_name)
  {
  echo "<br />";
  }

//Function to use when finding character data
function char($parser,$data)
  {
  echo $data;
  }

//Specify element handler
xml_set_element_handler($parser,"start","stop");

//Specify data handler
xml_set_character_data_handler($parser,"char");

//Open XML file
$fp=fopen("[B]http://71.59.233.240/RunUO/status.vor?get=CLIENTS[/B]","r");

//Read data
while ($data=fread($fp,4096))
  {
  xml_parse($parser,$data,feof($fp)) or 
  die (sprintf("XML Error: %s at line %d", 
  xml_error_string(xml_get_error_code($parser)),
  xml_get_current_line_number($parser)));
  }

//Free the XML parser
xml_parser_free($parser);
?>

I Get this
Code:
Accounts: 2
Clients: 0
Items: 94255
Mobiles: 2831

Items: 5882
Mobiles: 1088

7292937.5
67594496
2.0.50727.3603
Microsoft Windows NT 5.1.2600 Service Pack 3

And even if i do this in the browser by its self
Code:
http://71.59.233.240/RunUO/status.vor[B]?get=UPTIME[/B]

I still get the full thing.
Code:
  <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <STATUS>
- <TOTALS>
  <ACCOUNTS>2</ACCOUNTS> 
  <CLIENTS>0</CLIENTS> 
  <ITEMS>94185</ITEMS> 
  <MOBILES>2824</MOBILES> 
  </TOTALS>
- <SCRIPTS>
  <ITEMS>5882</ITEMS> 
  <MOBILES>1088</MOBILES> 
  </SCRIPTS>
- <SERVER>
  <UPTIME>7493546.875</UPTIME> 
  <MEMORY>68176936</MEMORY> 
  <FRAMEWORK>2.0.50727.3603</FRAMEWORK> 
  <OSVERSION>Microsoft Windows NT 5.1.2600 Service Pack 3</OSVERSION> 
  </SERVER>
  </STATUS>
 

Vorspire

Knight
Sorry, I didn't fully explain on how to capture URL-Queries in the WebObject :)

If you want to allow and process URL-Queries, you can use similar code to this:
URL-Query: ?text=HelloWorld
Code:
string text = GetQuery("text");

[COLOR="SeaGreen"]// text == "HelloWorld"[/COLOR]

Or by accessing the URL-Query list directly:
Code:
string text = String.Empty;

if(this.Queries.ContainsKey("text"))
    text = this.Queries["text"];

[COLOR="SeaGreen"]// text == "HelloWorld"[/COLOR]

All you would have to do is handle ?get=UPTIME like so:
(You can also have multiple values for one query, eg: ?get=UPTIME,CLIENTS
Code:
string getQ = this.GetQuery("get");
string[] list = new string[0];

if(getQ.IndexOfAny(',') != -1)
    list = getQ.Split(',', StringSplitOptions.RemoveEmptyEntries);
else
     list = new string[] { getQ };

foreach(string query in list)
{
      switch(query.ToUpper())
      {
            case "UPTIME": { AddHTML("<UPTIME>{0}</UPTIME>", [COLOR="Red"]UptimeVariable[/COLOR] ); } break;
            case "CLIENTS": { [COLOR="SeaGreen"]/* etc */[/COLOR] } break;
            [COLOR="SeaGreen"]/* etc */[/COLOR]
            default: { [COLOR="SeaGreen"]/* output all data */[/COLOR] } break;
      }
}

Note that the above code applies the the WebObject that is responsible for outputting XML data.
 

Nockar

Sorceror
Thanks for the information Vorspire. What you shared there makes sense. But I do not have the knowledge to put together wsobj.cs or do php parsing. I have not been exposed to enough of that type of code to be able to do it my self and there are not really any examples to look at.

I very much appreciate all the help you have given me. I will just have to wait for some one to release something that uses your xml web server.
 

Nockar

Sorceror
With this system. Could you get the item information on the items that people are warring? For example if my guy Charin was warring a hammer of ogre slaying, could that info be pulled into a xml file and modified some how?

If you could pull the item properties from worn item you could make those items viewable in a website. Probably even do it so when you mouse over what they were wearing (like ring, neck, bracelet, that sort of thing) you could have a little window popup showing the item properties.

Kind of like how its done on other MMO sites where you look at item properties in a web browser with a mouse over.

Though now that I think about it. Becase of the way UO uses layers, it would probably be better to have all the item properties in boxes off to one side some how. Then you just look at it manually.
 

Vorspire

Knight
Nockar;841323 said:
With this system. Could you get the item information on the items that people are warring? For example if my guy Charin was warring a hammer of ogre slaying, could that info be pulled into a xml file and modified some how?

If you could pull the item properties from worn item you could make those items viewable in a website. Probably even do it so when you mouse over what they were wearing (like ring, neck, bracelet, that sort of thing) you could have a little window popup showing the item properties.

Kind of like how its done on other MMO sites where you look at item properties in a web browser with a mouse over.

Though now that I think about it. Becase of the way UO uses layers, it would probably be better to have all the item properties in boxes off to one side some how. Then you just look at it manually.

Yes it can be done :)

Just think of WebObjects as Gumps, you can access anythig on your server and display it. The major difference is, the WebObject is a web-page and not an ingame interface :D

For example, you could have a WebObject that takes the Item.Serial as a URL-Query, you can then pull the item info using World.Items[serial] and then output the information whichever way you like.

Through clever use of CSS, it would be possible to layer seperate gump images to appear like the paperdoll, instead of generating one flat image as a paperdoll. - Tooltips can be handled by JavaScript, which you could bake-into the WebObject anyhow :p
 

Nockar

Sorceror
This is one cool system you designed here! I can see how a person could do a tone of different things with this. If I had the know how to do something like that I totally would.
 

Vorspire

Knight
Here's another little idea.

You know how most shards run on mul-file patches?

It would be extremely easy to create a WebObject page that would serve as a download page for the files that are on the actual server machine, which are shared by the shard, making sure that the patches players download are the same of the shard.

For example:
http://<host>/download.vor?file=TileData.mul

WSL already has an in-built "large file transfer" buffer that will process any data streams that are over 5MB in total, so the process can be done wth minimal effort.

Since WSL is a multi-threaded application, it is possible to serve these large file without interrupting the shard or player's game-play through lag.

----
The possibilities of this service are potentially endless :)
 

Nockar

Sorceror
That is a really great idea to!

What about integrating character creation on the website? Or even integrating account information back and fourth from the site to the server?

Would it be possible to make a change on the webpage and have that change take effect on the server?
 

Vorspire

Knight
I can only really say that the limitation of the usage of this system is equal to the imagination of the developer using it :)

WSL 1.3 will have full HTTP GET/POST support, so you can design HTML Forms using C# and the AddHTML method in the WebObject class.
It will also have full MySQL (Multiple Servers Support) integration too and will also provide PHP and ASP.NET parsing for Physical and Virtual WebObjects.

There will be many more features too, any of which you could add as a Custom Core Module.
 
I get this error:
[WebServer]: The WebServer service could not start becuse there seems to be a service listening on the specified hosts.

I guess it is becuse that port (80) is busy.. Read that I should change the port in a file that could be found in Cache/. Problem is that Cache is empty. even the zip is empty..
 

Ruined_Xz

Wanderer
Vorspire, I can not imagine how you accomplished this, it seems amazing, hosting your own web server directly out of your RunUO directory. Awsome man.

It actually is kind of intimidating to me, Im not sure if I would be able to use it. haha.
 

romanthebrain

Sorceror
I Already have this error and dont know to fix it .

Can anybody help me?

PHP:
Errors:
 + WebServer/WebObjects/ItemCatalog.wsobj.cs:
    CS0103: Line 84: The name 'Hues' does not exist in the current context
 + WebServer/WebObjects/StatusPage.wsobj.cs:
    CS0117: Line 30: 'Server.Accounting.Accounts' does not contain a definition
for 'Table'
 

Kennyd

Sorceror
old_school;816003 said:
Well I have a PHP web site An Ill def be looking to install this. So in theory how does this work? I mean in short. I just set up the script to run off my web page? An people just connect to my web page and play? Or do they need a copy of UO first?

lmfao... :D
 

Kennyd

Sorceror
old_school;816178 said:
Ok Im slowly understanding now. Let me see If I got this right. Its basicly like another Razor? So players can connect to your server. Am I right?

hahaha you're a real comedian ;)

edit: *keeps reading this topic to see what else you've posted* :D
 

Kennyd

Sorceror
Ruined_Xz;846990 said:
Vorspire, I can not imagine how you accomplished this, it seems amazing, hosting your own web server directly out of your RunUO directory. Awsome man.

What the hell are you talking about? lol
 

Del boy

Sorceror
Awesome Vorspire

I have one question(prob a noob question) I didnt even try searching the forums for this as I dont exactly know what I would search for

I have my website hosted on a different server to my game server, is there a way to get the information from the game to the website? :confused:

Thanks
 
Top