blob: 6b632d69e5241bd37c01dab58c4a5d7ea4aa3bd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
using Nwc.XmlRpc;
using System;
using System.Net;
using System.IO;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
namespace OpenGridServices.Manager
{
public class GridServerConnectionManager
{
private string ServerURL;
public LLUUID SessionID;
public bool connected=false;
public RegionBlock[][] WorldMap;
public bool Connect(string GridServerURL, string username, string password)
{
try {
this.ServerURL=GridServerURL;
Hashtable LoginParamsHT = new Hashtable();
LoginParamsHT["username"]=username;
LoginParamsHT["password"]=password;
ArrayList LoginParams = new ArrayList();
LoginParams.Add(LoginParamsHT);
XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams);
XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000);
if(GridResp.IsFault) {
connected=false;
return false;
} else {
Hashtable gridrespData = (Hashtable)GridResp.Value;
this.SessionID = new LLUUID((string)gridrespData["session_id"]);
connected=true;
return true;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
connected=false;
return false;
}
}
public void DownloadMap()
{
System.Net.WebClient mapdownloader = new WebClient();
Stream regionliststream = mapdownloader.OpenRead(ServerURL + "/regionlist");
RegionBlock TempRegionData;
XmlDocument doc = new XmlDocument();
doc.Load(regionliststream);
regionliststream.Close();
XmlNode rootnode = doc.FirstChild;
if (rootnode.Name != "regions")
{
// TODO - ERROR!
}
for(int i=0; i<=rootnode.ChildNodes.Count; i++)
{
if(rootnode.ChildNodes.Item(i).Name != "region") {
// TODO - ERROR!
} else {
TempRegionData = new RegionBlock();
}
}
}
public bool RestartServer()
{
return true;
}
public bool ShutdownServer()
{
try {
Hashtable ShutdownParamsHT = new Hashtable();
ArrayList ShutdownParams = new ArrayList();
ShutdownParamsHT["session_id"]=this.SessionID.ToString();
ShutdownParams.Add(ShutdownParamsHT);
XmlRpcRequest GridShutdownReq = new XmlRpcRequest("shutdown",ShutdownParams);
XmlRpcResponse GridResp = GridShutdownReq.Send(this.ServerURL,3000);
if(GridResp.IsFault) {
return false;
} else {
connected=false;
return true;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
return false;
}
}
public void DisconnectServer()
{
this.connected=false;
}
}
}
|