本文整理汇总了C#中Nwc.XmlRpc.XmlRpcResponse类的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcResponse类的具体用法?C# XmlRpcResponse怎么用?C# XmlRpcResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlRpcResponse类属于Nwc.XmlRpc命名空间,在下文中一共展示了XmlRpcResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LinkRegionRequest
/// <summary>
/// Someone wants to link to us
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
//string host = (string)requestData["host"];
//string portstr = (string)requestData["port"];
string name = (string)requestData["region_name"];
if (name == null)
name = string.Empty;
UUID regionID = UUID.Zero;
string externalName = string.Empty;
string imageURL = string.Empty;
ulong regionHandle = 0;
string reason = string.Empty;
bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out externalName, out imageURL, out reason);
Hashtable hash = new Hashtable();
hash["result"] = success.ToString();
hash["uuid"] = regionID.ToString();
hash["handle"] = regionHandle.ToString();
hash["region_image"] = imageURL;
hash["external_name"] = externalName;
XmlRpcResponse response = new XmlRpcResponse();
response.Value = hash;
return response;
}
示例2: Respond
/// <summary>Handle an HTTP request containing an XML-RPC request.</summary>
/// <remarks>This method deserializes the XML-RPC request, invokes the
/// described method, serializes the response (or fault) and sends the XML-RPC response
/// back as a valid HTTP page.
/// </remarks>
/// <param name="httpReq"><c>SimpleHttpRequest</c> containing the request.</param>
public void Respond(SimpleHttpRequest httpReq)
{
XmlRpcRequest xmlRpcReq = (XmlRpcRequest)_deserializer.Deserialize(httpReq.Input);
XmlRpcResponse xmlRpcResp = new XmlRpcResponse();
try
{
xmlRpcResp.Value = _server.Invoke(xmlRpcReq);
}
catch (XmlRpcException e)
{
xmlRpcResp.SetFault(e.FaultCode, e.FaultString);
}
catch (Exception e2)
{
xmlRpcResp.SetFault(XmlRpcErrorCodes.APPLICATION_ERROR,
XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": " + e2.Message);
}
if (Logger.Delegate != null)
Logger.WriteEntry(xmlRpcResp.ToString(), LogLevel.Information);
XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
httpReq.Output.Flush();
XmlTextWriter xml = new XmlTextWriter(httpReq.Output);
_serializer.Serialize(xml, xmlRpcResp);
xml.Flush();
httpReq.Output.Flush();
}
示例3: XmlRPCGetAvatarAppearance
public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
AvatarAppearance appearance;
Hashtable responseData;
if (requestData.Contains("owner"))
{
appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
if (appearance == null)
{
responseData = new Hashtable();
responseData["error_type"] = "no appearance";
responseData["error_desc"] = "There was no appearance found for this avatar";
}
else
{
responseData = appearance.ToHashTable();
}
}
else
{
responseData = new Hashtable();
responseData["error_type"] = "unknown_avatar";
responseData["error_desc"] = "The avatar appearance requested is not in the database";
}
response.Value = responseData;
return response;
}
示例4: Parse
public static XmlRpcResponse Parse(StreamReader xmlData)
{
XmlTextReader reader = new XmlTextReader(xmlData);
XmlRpcResponse response = new XmlRpcResponse();
bool done = false;
while (!done && reader.Read())
{
Singleton.ParseNode(reader); // Parent parse...
switch (reader.NodeType)
{
case XmlNodeType.EndElement:
switch (reader.Name)
{
case FAULT:
response.Value = Singleton._value;
response.IsFault = true;
break;
case PARAM:
response.Value = Singleton._value;
Singleton._value = null;
Singleton._text = null;
break;
}
break;
default:
break;
}
}
return response;
}
示例5: GenerateKeyMethod
public XmlRpcResponse GenerateKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
XmlRpcResponse response = new XmlRpcResponse();
if (request.Params.Count < 2)
{
response.IsFault = true;
response.SetFault(-1, "Invalid parameters");
return response;
}
// Verify the key of who's calling
UUID userID = UUID.Zero;
string authKey = string.Empty;
UUID.TryParse((string)request.Params[0], out userID);
authKey = (string)request.Params[1];
m_log.InfoFormat("[AUTH HANDLER] GenerateKey called with authToken {0}", authKey);
string newKey = string.Empty;
newKey = m_LocalService.GetKey(userID, authKey.ToString());
response.Value = (string)newKey;
return response;
}
示例6: Response
public void Response()
{
XmlRpcResponse respIn = new XmlRpcResponse(22,"Help Me");
String str = (new XmlRpcResponseSerializer()).Serialize(respIn);
XmlRpcResponse respOut = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(str);
Assertion.AssertEquals("faultcode", respIn.FaultCode, respOut.FaultCode);
Assertion.AssertEquals("faultstring", respIn.FaultString, respOut.FaultString);
}
示例7: Login
private static void Login(XmlRpcResponse response) {
Hashtable values = (Hashtable)response.Value;
if (values.Contains("agent_id") && values.Contains("session_id")) {
// remember our agentID and sessionID
agentID = new LLUUID((string)values["agent_id"]);
sessionID = new LLUUID((string)values["session_id"]);
// start a new thread that reads lines from the console
(new Thread(new ThreadStart(ReadFromConsole))).Start();
}
}
示例8: CreateFailureResponse
public XmlRpcResponse CreateFailureResponse(string reason, string message, bool loginSuccess)
{
Hashtable responseData = new Hashtable(3);
responseData["reason"] = reason;
responseData["message"] = message;
responseData["login"] = loginSuccess.ToString().ToLower();
XmlRpcResponse response = new XmlRpcResponse();
response.Value = responseData;
return response;
}
示例9: AgentIsComingHome
public XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
//string host = (string)requestData["host"];
//string portstr = (string)requestData["port"];
string sessionID_str = (string)requestData["sessionID"];
UUID sessionID = UUID.Zero;
UUID.TryParse (sessionID_str, out sessionID);
string gridName = (string)requestData["externalName"];
bool success = m_HomeUsersService.AgentIsComingHome (sessionID, gridName);
Hashtable hash = new Hashtable ();
hash["result"] = success.ToString ();
XmlRpcResponse response = new XmlRpcResponse {Value = hash};
return response;
}
示例10: FriendListItemListtoXmlRPCResponse
public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
// Query Result Information
responseData["avcount"] = returnUsers.Count.ToString();
for (int i = 0; i < returnUsers.Count; i++)
{
responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString();
responseData["friendID" + i] = returnUsers[i].Friend.ToString();
responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString();
responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString();
}
response.Value = responseData;
return response;
}
示例11: BuyFunc
public XmlRpcResponse BuyFunc(XmlRpcRequest request, IPEndPoint ep)
{
Hashtable requestData = (Hashtable)request.Params[0];
bool success = false;
if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy") &&
m_connector.GetConfig().CanBuyCurrencyInworld)
{
UUID agentId;
if (UUID.TryParse((string)requestData["agentId"], out agentId))
{
uint amountBuying = uint.Parse(requestData["currencyBuy"].ToString());
success = m_connector.InworldCurrencyBuyTransaction(agentId, amountBuying, ep);
}
}
XmlRpcResponse returnval = new XmlRpcResponse();
Hashtable returnresp = new Hashtable { { "success", success } };
returnval.Value = returnresp;
return returnval;
}
示例12: XmlRPCCheckAuthSessionSwitch
public XmlRpcResponse XmlRPCCheckAuthSessionSwitch(XmlRpcRequest request, IPEndPoint remoteClient)
{
Hashtable requestData = (Hashtable)request.Params[0];
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id"))
{
UUID avatar;
UUID sessionID;
if (UUID.TryParse((string)requestData["avatar_uuid"], out avatar) &&
UUID.TryParse((string)requestData["session_id"], out sessionID))
{
if (m_LoggingInClients.ContainsKey(avatar))
{
if (m_LoggingInClients[avatar] == sessionID)
{
responseData["auth_session"] = "TRUE";
}
else
{
responseData["auth_session"] = "FALSE";
}
m_LoggingInClients.Remove(avatar);
response.Value = responseData;
return response;
}
else
{
// try normal OpenSim authentication
return m_UserLoginService.XmlRPCCheckAuthSession(request, remoteClient);
}
}
}
responseData["auth_session"] = "FALSE";
response.Value = responseData;
return response;
}
示例13: Deserialize
/// <summary>Static method that parses XML data into a response using the Singleton.</summary>
/// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC response.</param>
/// <returns><c>XmlRpcResponse</c> object resulting from the parse.</returns>
override public Object Deserialize(TextReader xmlData)
{
XmlTextReader reader = new XmlTextReader(xmlData);
XmlRpcResponse response = new XmlRpcResponse();
bool done = false;
lock(this)
{
Reset();
while (!done && reader.Read())
{
DeserializeNode(reader); // Parent parse...
switch (reader.NodeType)
{
case XmlNodeType.EndElement:
switch (reader.Name)
{
case FAULT:
response.Value = _value;
response.IsFault = true;
break;
case PARAM:
response.Value = _value;
_value = null;
_text = null;
break;
}
break;
default:
break;
}
}
}
return response;
}
示例14: ClearXmlRpcHandler
public XmlRpcResponse ClearXmlRpcHandler(XmlRpcRequest request, IPEndPoint client)
{
// AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID);
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
Hashtable resp = new Hashtable();
if (requestData.ContainsKey("RegionID"))
{
UUID regionID = UUID.Parse((string)requestData["RegionID"]);
m_scene = SelectRegion(regionID);
m_scene.DeleteAllSceneObjects();
}
else
{
resp["success"] = false;
resp["error"] = "no RegionID provided";
response.Value = resp;
return response;
}
// return ok;
resp["success"] = true;
response.Value = resp;
return response;
}
示例15: Serialize
static public void Serialize(XmlTextWriter output, XmlRpcResponse response)
{
output.WriteStartDocument();
output.WriteStartElement(METHOD_RESPONSE);
if (response.IsFault)
output.WriteStartElement(FAULT);
else
{
output.WriteStartElement(PARAMS);
output.WriteStartElement(PARAM);
}
output.WriteStartElement(VALUE);
SerializeObject(output,response.Value);
output.WriteEndElement();
output.WriteEndElement();
if (!response.IsFault)
output.WriteEndElement();
output.WriteEndElement();
}