mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 03:06:05 +08:00
cosmetics on offline msg v2
This commit is contained in:
@@ -93,21 +93,30 @@ namespace OpenSim.OfflineIM
|
||||
if (ret == null)
|
||||
return ims;
|
||||
|
||||
if (!ret.ContainsKey("RESULT"))
|
||||
if (!ret.TryGetValue("RESULT", out object resultobj))
|
||||
return ims;
|
||||
|
||||
string result = ret["RESULT"].ToString();
|
||||
if (result == "NULL" || result.ToLower() == "false")
|
||||
if(resultobj is string result)
|
||||
{
|
||||
string reason = ret.ContainsKey("REASON") ? ret["REASON"].ToString() : "Unknown error";
|
||||
m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: GetMessages for {0} failed: {1}", principalID, reason);
|
||||
return ims;
|
||||
if (result == "NULL" || result.Equals("false", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
if (ret.TryGetValue("REASON", out object rso))
|
||||
m_log.Debug($"[OfflineIM.V2.RemoteConnector]: GetMessages for {principalID} failed: {rso}");
|
||||
else
|
||||
m_log.Debug($"[OfflineIM.V2.RemoteConnector]: GetMessages for {principalID} failed: Unknown error");
|
||||
return ims;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
|
||||
else if(resultobj is Dictionary<string, object> resultdic)
|
||||
{
|
||||
GridInstantMessage m = OfflineIMDataUtils.GridInstantMessage((Dictionary<string, object>)v);
|
||||
ims.Add(m);
|
||||
foreach (object v in resultdic.Values)
|
||||
{
|
||||
if (v is Dictionary<string, object> vdic)
|
||||
{
|
||||
GridInstantMessage m = OfflineIMDataUtils.GridInstantMessage(vdic);
|
||||
ims.Add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ims;
|
||||
@@ -115,7 +124,6 @@ namespace OpenSim.OfflineIM
|
||||
|
||||
public bool StoreMessage(GridInstantMessage im, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
Dictionary<string, object> sendData = OfflineIMDataUtils.GridInstantMessage(im);
|
||||
|
||||
Dictionary<string, object> ret = MakeRequest("STORE", sendData);
|
||||
@@ -126,13 +134,20 @@ namespace OpenSim.OfflineIM
|
||||
return false;
|
||||
}
|
||||
|
||||
string result = ret["RESULT"].ToString();
|
||||
if (result == "NULL" || result.ToLower() == "false")
|
||||
if(ret.TryGetValue("RESULT", out object o))
|
||||
{
|
||||
reason = ret.ContainsKey("REASON") ? ret["REASON"].ToString() : "Unknown error";
|
||||
return false;
|
||||
string result = o.ToString();
|
||||
if (result == "NULL" || result.Equals("false", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
if(ret.TryGetValue("REASON", out object ro))
|
||||
reason = ro.ToString();
|
||||
else
|
||||
reason = "Unknown error";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -160,8 +175,7 @@ namespace OpenSim.OfflineIM
|
||||
ServerUtils.BuildQueryString(sendData),
|
||||
m_Auth);
|
||||
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
|
||||
reply);
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||
|
||||
return replyData;
|
||||
}
|
||||
|
||||
@@ -50,49 +50,50 @@ namespace OpenSim.Services.Interfaces
|
||||
public static GridInstantMessage GridInstantMessage(Dictionary<string, object> dict)
|
||||
{
|
||||
GridInstantMessage im = new GridInstantMessage();
|
||||
object otmp;
|
||||
|
||||
if (dict.ContainsKey("BinaryBucket") && dict["BinaryBucket"] != null)
|
||||
im.binaryBucket = OpenMetaverse.Utils.HexStringToBytes(dict["BinaryBucket"].ToString(), true);
|
||||
if (dict.TryGetValue("BinaryBucket", out otmp) && otmp is string bbs)
|
||||
im.binaryBucket = OpenMetaverse.Utils.HexStringToBytes(bbs, true);
|
||||
|
||||
if (dict.ContainsKey("Dialog") && dict["Dialog"] != null)
|
||||
im.dialog = byte.Parse(dict["Dialog"].ToString());
|
||||
if (dict.TryGetValue("Dialog", out otmp) && otmp is string ds)
|
||||
im.dialog = byte.Parse(ds);
|
||||
|
||||
if (dict.ContainsKey("FromAgentID") && dict["FromAgentID"] != null)
|
||||
im.fromAgentID = new Guid(dict["FromAgentID"].ToString());
|
||||
if (dict.TryGetValue("FromAgentID", out otmp) && otmp is string faid)
|
||||
im.fromAgentID = new Guid(faid);
|
||||
|
||||
if (dict.ContainsKey("FromAgentName") && dict["FromAgentName"] != null)
|
||||
im.fromAgentName = dict["FromAgentName"].ToString();
|
||||
if (dict.TryGetValue("FromAgentName", out otmp) && otmp is string fan)
|
||||
im.fromAgentName = fan;
|
||||
else
|
||||
im.fromAgentName = string.Empty;
|
||||
|
||||
if (dict.ContainsKey("FromGroup") && dict["FromGroup"] != null)
|
||||
im.fromGroup = bool.Parse(dict["FromGroup"].ToString());
|
||||
if (dict.TryGetValue("FromGroup", out otmp) && otmp is string fg)
|
||||
im.fromGroup = bool.Parse(fg);
|
||||
|
||||
if (dict.ContainsKey("SessionID") && dict["SessionID"] != null)
|
||||
im.imSessionID = new Guid(dict["SessionID"].ToString());
|
||||
if (dict.TryGetValue("SessionID", out otmp) && otmp is string sid)
|
||||
im.imSessionID = new Guid(sid);
|
||||
|
||||
if (dict.ContainsKey("Message") && dict["Message"] != null)
|
||||
im.message = dict["Message"].ToString();
|
||||
if (dict.TryGetValue("Message", out otmp) && otmp is string msg)
|
||||
im.message = msg;
|
||||
else
|
||||
im.message = string.Empty;
|
||||
|
||||
if (dict.ContainsKey("Offline") && dict["Offline"] != null)
|
||||
im.offline = byte.Parse(dict["Offline"].ToString());
|
||||
if (dict.TryGetValue("Offline", out otmp) && otmp is string off)
|
||||
im.offline = byte.Parse(off);
|
||||
|
||||
if (dict.ContainsKey("EstateID") && dict["EstateID"] != null)
|
||||
im.ParentEstateID = UInt32.Parse(dict["EstateID"].ToString());
|
||||
if (dict.TryGetValue("EstateID", out otmp) && otmp is string eid)
|
||||
im.ParentEstateID = UInt32.Parse(eid);
|
||||
|
||||
if (dict.ContainsKey("Position") && dict["Position"] != null)
|
||||
im.Position = Vector3.Parse(dict["Position"].ToString());
|
||||
if (dict.TryGetValue("Position", out otmp) && otmp is string vpos)
|
||||
im.Position = Vector3.Parse(vpos);
|
||||
|
||||
if (dict.ContainsKey("RegionID") && dict["RegionID"] != null)
|
||||
im.RegionID = new Guid(dict["RegionID"].ToString());
|
||||
if (dict.TryGetValue("RegionID", out otmp) && otmp is string rid)
|
||||
im.RegionID = new Guid(rid);
|
||||
|
||||
if (dict.ContainsKey("Timestamp") && dict["Timestamp"] != null)
|
||||
im.timestamp = UInt32.Parse(dict["Timestamp"].ToString());
|
||||
if (dict.TryGetValue("Timestamp", out otmp) && otmp is string ts)
|
||||
im.timestamp = UInt32.Parse(ts);
|
||||
|
||||
if (dict.ContainsKey("ToAgentID") && dict["ToAgentID"] != null)
|
||||
im.toAgentID = new Guid(dict["ToAgentID"].ToString());
|
||||
if (dict.TryGetValue("ToAgentID", out otmp) && otmp is string tid)
|
||||
im.toAgentID = new Guid(tid);
|
||||
|
||||
return im;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user