mirror of
https://github.com/opensim/opensim.git
synced 2026-08-13 05:05:43 +08:00
Added some exception handling
This commit is contained in:
@@ -11,18 +11,23 @@ namespace OpenGridServices.Manager
|
||||
|
||||
public bool Connect(string GridServerURL, string username, string password)
|
||||
{
|
||||
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) {
|
||||
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) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Console.WriteLine(e.ToString());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,11 @@ namespace OpenGridServices.Manager
|
||||
switch(cmd) {
|
||||
case "connect_to_gridserver":
|
||||
win.SetStatus("Connecting to grid server...");
|
||||
gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3]);
|
||||
if(gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3])) {
|
||||
win.SetStatus("Connected OK");
|
||||
} else {
|
||||
win.SetStatus("Could not connect");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user