本文整理汇总了C#中OpenSim.Services.Connectors.Hypergrid.UserAgentServiceConnector类的典型用法代码示例。如果您正苦于以下问题:C# UserAgentServiceConnector类的具体用法?C# UserAgentServiceConnector怎么用?C# UserAgentServiceConnector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserAgentServiceConnector类属于OpenSim.Services.Connectors.Hypergrid命名空间,在下文中一共展示了UserAgentServiceConnector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUserServerURL
public string GetUserServerURL(UUID userID, string serverType)
{
UserData userdata;
lock (m_UserCache)
m_UserCache.TryGetValue(userID, out userdata);
if (userdata != null)
{
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID);
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
{
return userdata.ServerURLs[serverType].ToString();
}
if (!string.IsNullOrEmpty(userdata.HomeURL))
{
//m_log.DebugFormat(
// "[USER MANAGEMENT MODULE]: Did not find url type {0} so requesting urls from '{1}' for {2}",
// serverType, userdata.HomeURL, userID);
UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
try
{
userdata.ServerURLs = uConn.GetServerURLs(userID);
}
catch (Exception e)
{
m_log.Debug("[USER MANAGEMENT MODULE]: GetServerURLs call failed ", e);
userdata.ServerURLs = new Dictionary<string, object>();
}
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
return userdata.ServerURLs[serverType].ToString();
}
}
return string.Empty;
}
示例2: StatusNotify
//.........这里部分代码省略.........
//private void CollectOnlineFriendsElsewhere(UUID userID, List<string> foreignFriends)
//{
// // let's divide the friends on a per-domain basis
// Dictionary<string, List<string>> friendsPerDomain = new Dictionary<string, List<string>>();
// foreach (string friend in foreignFriends)
// {
// UUID friendID;
// if (!UUID.TryParse(friend, out friendID))
// {
// // it's a foreign friend
// string url = string.Empty, tmp = string.Empty;
// if (Util.ParseUniversalUserIdentifier(friend, out friendID, out url, out tmp, out tmp, out tmp))
// {
// if (!friendsPerDomain.ContainsKey(url))
// friendsPerDomain[url] = new List<string>();
// friendsPerDomain[url].Add(friend);
// }
// }
// }
// // Now, call those worlds
// foreach (KeyValuePair<string, List<string>> kvp in friendsPerDomain)
// {
// List<string> ids = new List<string>();
// foreach (string f in kvp.Value)
// ids.Add(f);
// UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key);
// List<UUID> online = uConn.GetOnlineFriends(userID, ids);
// // Finally send the notifications to the user
// // this whole process may take a while, so let's check at every
// // iteration that the user is still here
// IClientAPI client = LocateClientObject(userID);
// if (client != null)
// client.SendAgentOnline(online.ToArray());
// else
// break;
// }
//}
protected override void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online)
{
// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID);
// First, let's divide the friends on a per-domain basis
Dictionary<string, List<FriendInfo>> friendsPerDomain = new Dictionary<string, List<FriendInfo>>();
foreach (FriendInfo friend in friendList)
{
UUID friendID;
if (UUID.TryParse(friend.Friend, out friendID))
{
if (!friendsPerDomain.ContainsKey("local"))
friendsPerDomain["local"] = new List<FriendInfo>();
friendsPerDomain["local"].Add(friend);
}
else
{
// it's a foreign friend
string url = string.Empty, tmp = string.Empty;
if (Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out url, out tmp, out tmp, out tmp))
{
// Let's try our luck in the local sim. Who knows, maybe it's here
if (LocalStatusNotification(userID, friendID, online))
continue;
if (!friendsPerDomain.ContainsKey(url))
friendsPerDomain[url] = new List<FriendInfo>();
friendsPerDomain[url].Add(friend);
}
}
}
// For the local friends, just call the base method
// Let's do this first of all
if (friendsPerDomain.ContainsKey("local"))
base.StatusNotify(friendsPerDomain["local"], userID, online);
foreach (KeyValuePair<string, List<FriendInfo>> kvp in friendsPerDomain)
{
if (kvp.Key != "local")
{
// For the others, call the user agent service
List<string> ids = new List<string>();
foreach (FriendInfo f in kvp.Value)
ids.Add(f.Friend);
UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key);
List<UUID> friendsOnline = uConn.StatusNotification(ids, userID, online);
if (online && friendsOnline.Count > 0)
{
IClientAPI client = LocateClientObject(userID);
if (client != null)
client.SendAgentOnline(friendsOnline.ToArray());
}
}
}
// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting StatusNotify for {0}", userID);
}
示例3: ProcessFriendshipOffered
private void ProcessFriendshipOffered(UUID fromID, String fromName, UUID toID, String message)
{
// Great, it's a genuine request. Let's proceed.
// But now we need to confirm that the requester is who he says he is
// before we act on the friendship request.
if (!fromName.Contains("@"))
return;
string[] parts = fromName.Split(new char[] {'@'});
if (parts.Length != 2)
return;
string uriStr = "http://" + parts[1];
try
{
new Uri(uriStr);
}
catch (UriFormatException)
{
return;
}
UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr);
Dictionary<string, object> servers = uasConn.GetServerURLs(fromID);
if (!servers.ContainsKey("FriendsServerURI"))
return;
HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(servers["FriendsServerURI"].ToString());
if (!friendsConn.ValidateFriendshipOffered(fromID, toID))
{
m_log.WarnFormat("[HGFRIENDS SERVICE]: Friendship request from {0} to {1} is invalid. Impersonations?", fromID, toID);
return;
}
string fromUUI = Util.UniversalIdentifier(fromID, parts[0], "@" + parts[1], uriStr);
// OK, we're good!
ForwardToSim("FriendshipOffered", fromID, fromName, fromUUI, toID, message);
}
示例4: VerifyClient
public bool VerifyClient(AgentCircuitData aCircuit, string token)
{
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
{
string url = aCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService security = new UserAgentServiceConnector(url);
return security.VerifyClient(aCircuit.SessionID, token);
}
else
{
m_log.DebugFormat(
"[HG ENTITY TRANSFER MODULE]: Agent {0} {1} does not have a HomeURI OH NO!",
aCircuit.firstname, aCircuit.lastname);
}
return false;
}
示例5: GetUserProfileData
//
// Get the UserAccountBits
//
private bool GetUserProfileData(UUID userID, out Dictionary<string, object> userInfo)
{
IUserManagement uManage = UserManagementModule;
Dictionary<string,object> info = new Dictionary<string, object>();
if (!uManage.IsLocalGridUser(userID))
{
// Is Foreign
string home_url = uManage.GetUserServerURL(userID, "HomeURI");
if (String.IsNullOrEmpty(home_url))
{
info["user_flags"] = 0;
info["user_created"] = 0;
info["user_title"] = "Unavailable";
userInfo = info;
return true;
}
UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url);
Dictionary<string, object> account = uConn.GetUserInfo(userID);
if (account.Count > 0)
{
if (account.ContainsKey("user_flags"))
info["user_flags"] = account["user_flags"];
else
info["user_flags"] = "";
if (account.ContainsKey("user_created"))
info["user_created"] = account["user_created"];
else
info["user_created"] = "";
info["user_title"] = "HG Visitor";
}
else
{
info["user_flags"] = 0;
info["user_created"] = 0;
info["user_title"] = "HG Visitor";
}
userInfo = info;
return true;
}
else
{
// Is local
Scene scene = m_Scenes[0];
IUserAccountService uas = scene.UserAccountService;
UserAccount account = uas.GetUserAccount(scene.RegionInfo.ScopeID, userID);
info["user_flags"] = account.UserFlags;
info["user_created"] = account.Created;
if (!String.IsNullOrEmpty(account.UserTitle))
info["user_title"] = account.UserTitle;
else
info["user_title"] = "";
userInfo = info;
return false;
}
}
示例6: OnConnectionClosed
void OnConnectionClosed(IClientAPI obj)
{
if (obj.IsLoggingOut)
{
object sp = null;
if (obj.Scene.TryGetScenePresence(obj.AgentId, out sp))
{
if (((ScenePresence)sp).IsChildAgent)
return;
}
// Let's find out if this is a foreign user or a local user
UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, obj.AgentId);
if (account != null)
{
// local grid user
return;
}
AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
{
string url = aCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService security = new UserAgentServiceConnector(url);
security.LogoutAgent(obj.AgentId, obj.SessionId);
//m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url);
}
else
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: HomeURI not found for agent {0} logout", obj.AgentId);
}
}
示例7: CreateAgent
protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout)
{
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI);
reason = string.Empty;
logout = false;
int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID);
if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
{
// this user is going to another grid
// for local users, check if HyperGrid teleport is allowed, based on user level
if (Scene.UserManagementModule.IsLocalGridUser(sp.UUID) && sp.UserLevel < m_levelHGTeleport)
{
m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel.");
reason = "Hypergrid teleport not allowed";
return false;
}
if (agentCircuit.ServiceURLs.ContainsKey("HomeURI"))
{
string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService connector;
if (userAgentDriver.Equals(m_ThisHomeURI) && m_UAS != null)
connector = m_UAS;
else
connector = new UserAgentServiceConnector(userAgentDriver);
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, false, out reason);
logout = success; // flag for later logout from this grid; this is an HG TP
if (success)
sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout);
return success;
}
else
{
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent does not have a HomeURI address");
return false;
}
}
return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout);
}
示例8: TryGetRecipientUUI
private string TryGetRecipientUUI(UUID fromAgent, UUID toAgent)
{
// Let's call back the fromAgent's user agent service
// Maybe that service knows about the toAgent
IClientAPI client = LocateClientObject(fromAgent);
if (client != null)
{
AgentCircuitData circuit = m_Scenes[0].AuthenticateHandler.GetAgentCircuitData(client.AgentId);
if (circuit != null)
{
if (circuit.ServiceURLs.ContainsKey("HomeURI"))
{
string uasURL = circuit.ServiceURLs["HomeURI"].ToString();
m_log.DebugFormat("[HG MESSAGE TRANSFER]: getting UUI of user {0} from {1}", toAgent, uasURL);
UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uasURL);
string agentUUI = string.Empty;
try
{
agentUUI = uasConn.GetUUI(fromAgent, toAgent);
}
catch (Exception e) {
m_log.Debug("[HG MESSAGE TRANSFER]: GetUUI call failed ", e);
}
return agentUUI;
}
}
}
return string.Empty;
}
示例9: GetUserServerURL
public string GetUserServerURL(UUID userID, string serverType)
{
UserData userdata;
if(!GetUser(userID, out userdata))
{
return string.Empty;
}
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
{
return userdata.ServerURLs[serverType].ToString();
}
if (!string.IsNullOrEmpty(userdata.HomeURL))
{
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID);
UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
try
{
userdata.ServerURLs = uConn.GetServerURLs(userID);
}
catch(System.Net.WebException e)
{
m_log.DebugFormat("[USER MANAGEMENT MODULE]: GetServerURLs call failed {0}", e.Message);
userdata.ServerURLs = new Dictionary<string, object>();
}
catch (Exception e)
{
m_log.Debug("[USER MANAGEMENT MODULE]: GetServerURLs call failed ", e);
userdata.ServerURLs = new Dictionary<string, object>();
}
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
return userdata.ServerURLs[serverType].ToString();
}
return string.Empty;
}
示例10: AddAdditionalUsers
protected override void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users)
{
if (query.Contains("@")) // [email protected], maybe?
{
string[] words = query.Split(new char[] { '@' });
if (words.Length != 2)
{
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Malformed address {0}", query);
return;
}
words[0] = words[0].Trim(); // it has at least 1
words[1] = words[1].Trim();
if (words[0] == String.Empty) // query was @foo.com?
{
foreach (UserData d in m_UserCache.Values)
{
if (d.LastName.ToLower().StartsWith("@" + words[1].ToLower()))
users.Add(d);
}
// We're done
return;
}
// words.Length == 2 and words[0] != string.empty
// [email protected] ?
foreach (UserData d in m_UserCache.Values)
{
if (d.LastName.StartsWith("@") &&
d.FirstName.ToLower().Equals(words[0].ToLower()) &&
d.LastName.ToLower().Equals("@" + words[1].ToLower()))
{
users.Add(d);
// It's cached. We're done
return;
}
}
// This is it! Let's ask the other world
if (words[0].Contains("."))
{
string[] names = words[0].Split(new char[] { '.' });
if (names.Length >= 2)
{
string uriStr = "http://" + words[1];
// Let's check that the last name is a valid address
try
{
new Uri(uriStr);
}
catch (UriFormatException)
{
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Malformed address {0}", uriStr);
return;
}
UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr);
UUID userID = uasConn.GetUUID(names[0], names[1]);
if (!userID.Equals(UUID.Zero))
{
UserData ud = new UserData();
ud.Id = userID;
ud.FirstName = words[0];
ud.LastName = "@" + words[1];
users.Add(ud);
AddUser(userID, names[0], names[1], uriStr);
m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0}@{1} found", words[0], words[1]);
}
else
m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0}@{1} not found", words[0], words[1]);
}
}
}
//else
//{
// foreach (UserData d in m_UserCache.Values)
// {
// if (d.LastName.StartsWith("@") &&
// (d.FirstName.ToLower().StartsWith(query.ToLower()) ||
// d.LastName.ToLower().StartsWith(query.ToLower())))
// users.Add(d);
// }
//}
}
示例11: Authenticate
protected bool Authenticate(AgentCircuitData aCircuit, out string message)
{
message = "";
if (!CheckAddress(aCircuit.ServiceSessionID))
{
message = "Please use " + m_Uri.GetLeftPart(UriPartial.Authority) + " instead.";
return false;
}
if (string.IsNullOrEmpty(aCircuit.IPAddress))
{
m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide a client IP address.");
return false;
}
string userURL = string.Empty;
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
if (userURL == string.Empty)
{
m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL");
message = "Agent did not provide an authentication server URL.";
return false;
}
if (userURL == m_ExternalName)
{
return m_UserAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID);
}
else
{
IUserAgentService userAgentService = new UserAgentServiceConnector(userURL);
try
{
return userAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID);
}
catch
{
m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", userURL);
message = string.Format("Unable to contact authentication service at {0}.", userURL);
return false;
}
}
}
示例12: GetUserServerURL
public string GetUserServerURL(UUID userID, string serverType)
{
UserData userdata;
lock (m_UserCache)
m_UserCache.TryGetValue(userID, out userdata);
if (userdata != null)
{
// m_log.DebugFormat("[UserManagementModule]: Requested url type {0} for {1}", serverType, userID);
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
{
return userdata.ServerURLs[serverType].ToString();
}
if (userdata.HomeURL != null && userdata.HomeURL != string.Empty)
{
//m_log.DebugFormat(
// "[UserManagementModule]: Did not find url type {0} so requesting urls from '{1}' for {2}",
// serverType, userdata.HomeURL, userID);
UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
userdata.ServerURLs = uConn.GetServerURLs(userID);
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
return userdata.ServerURLs[serverType].ToString();
}
}
return string.Empty;
}
示例13: GetUserServerURL
public string GetUserServerURL(UUID userID, string serverType)
{
if (m_UserCache.ContainsKey(userID))
{
UserData userdata = m_UserCache[userID];
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
return userdata.ServerURLs[serverType].ToString();
if (userdata.HomeURL != string.Empty)
{
UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
userdata.ServerURLs = uConn.GetServerURLs(userID);
if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
return userdata.ServerURLs[serverType].ToString();
}
}
return string.Empty;
}
示例14: OnConnectionClosed
void OnConnectionClosed(IClientAPI obj)
{
if (obj.IsLoggingOut)
{
AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
{
string url = aCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService security = new UserAgentServiceConnector(url);
security.LogoutAgent(obj.AgentId, obj.SessionId);
//m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url);
}
else
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: HomeURI not found for agent {0} logout", obj.AgentId);
}
}
示例15: CreateAgent
protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout)
{
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI);
reason = string.Empty;
logout = false;
int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
{
// this user is going to another grid
if (agentCircuit.ServiceURLs.ContainsKey("HomeURI"))
{
string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver);
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
logout = success; // flag for later logout from this grid; this is an HG TP
return success;
}
else
{
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent does not have a HomeURI address");
return false;
}
}
return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
}