本文整理汇总了C#中OpenSim.Framework.GridInstantMessage类的典型用法代码示例。如果您正苦于以下问题:C# GridInstantMessage类的具体用法?C# GridInstantMessage怎么用?C# GridInstantMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridInstantMessage类属于OpenSim.Framework命名空间,在下文中一共展示了GridInstantMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendMessageToGroup
public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
{
if (m_debugEnabled)
MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: {0} called", MethodBase.GetCurrentMethod().Name);
// Copy Message
GridInstantMessage msg = new GridInstantMessage
{
imSessionID = groupID,
fromAgentName = im.fromAgentName,
message = im.message,
dialog = (byte) InstantMessageDialog.SessionSend,
offline = 0,
ParentEstateID = 0,
Position = Vector3.Zero,
RegionID = UUID.Zero
};
ChatSession session = m_groupData.GetSession(im.imSessionID);
msg.binaryBucket = Utils.StringToBytes(session.Name);
msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
msg.fromAgentID = im.fromAgentID;
msg.fromGroup = true;
Util.FireAndForget(SendInstantMessages, msg);
}
示例2: SendInstantMessages
public virtual void SendInstantMessages(GridInstantMessage im, List<UUID> AgentsToSendTo)
{
//Check for local users first
List<UUID> RemoveUsers = new List<UUID>();
foreach (IScene scene in m_Scenes)
{
foreach (UUID t in AgentsToSendTo)
{
IScenePresence user;
if (!RemoveUsers.Contains(t) &&
scene.TryGetScenePresence(t, out user))
{
// Local message
user.ControllingClient.SendInstantMessage(im);
RemoveUsers.Add(t);
}
}
}
//Clear the local users out
foreach (UUID agentID in RemoveUsers)
{
AgentsToSendTo.Remove(agentID);
}
SendMultipleGridInstantMessageViaXMLRPC(im, AgentsToSendTo);
}
示例3: HGIM_001
public void HGIM_001()
{
GridInstantMessage im = new GridInstantMessage();
im.fromAgentID = new Guid();
im.toAgentID = new Guid();
im.message = "Hello";
im.imSessionID = new Guid();
bool success = InstantMessageServiceConnector.SendInstantMessage(DemonServer.Address, im);
Assert.IsFalse(success, "Sending of IM succeeded, but it should have failed");
}
示例4: GridInstantMessage
public static GridInstantMessage GridInstantMessage(Dictionary<string, object> dict)
{
GridInstantMessage im = new GridInstantMessage();
if (dict.ContainsKey("BinaryBucket") && dict["BinaryBucket"] != null)
im.binaryBucket = OpenMetaverse.Utils.HexStringToBytes(dict["BinaryBucket"].ToString(), true);
if (dict.ContainsKey("Dialog") && dict["Dialog"] != null)
im.dialog = byte.Parse(dict["Dialog"].ToString());
if (dict.ContainsKey("FromAgentID") && dict["FromAgentID"] != null)
im.fromAgentID = new Guid(dict["FromAgentID"].ToString());
if (dict.ContainsKey("FromAgentName") && dict["FromAgentName"] != null)
im.fromAgentName = dict["FromAgentName"].ToString();
else
im.fromAgentName = string.Empty;
if (dict.ContainsKey("FromGroup") && dict["FromGroup"] != null)
im.fromGroup = bool.Parse(dict["FromGroup"].ToString());
if (dict.ContainsKey("SessionID") && dict["SessionID"] != null)
im.imSessionID = new Guid(dict["SessionID"].ToString());
if (dict.ContainsKey("Message") && dict["Message"] != null)
im.message = dict["Message"].ToString();
else
im.message = string.Empty;
if (dict.ContainsKey("Offline") && dict["Offline"] != null)
im.offline = byte.Parse(dict["Offline"].ToString());
if (dict.ContainsKey("EstateID") && dict["EstateID"] != null)
im.ParentEstateID = UInt32.Parse(dict["EstateID"].ToString());
if (dict.ContainsKey("Position") && dict["Position"] != null)
im.Position = Vector3.Parse(dict["Position"].ToString());
if (dict.ContainsKey("RegionID") && dict["RegionID"] != null)
im.RegionID = new Guid(dict["RegionID"].ToString());
if (dict.ContainsKey("Timestamp") && dict["Timestamp"] != null)
im.timestamp = UInt32.Parse(dict["Timestamp"].ToString());
if (dict.ContainsKey("ToAgentID") && dict["ToAgentID"] != null)
im.toAgentID = new Guid(dict["ToAgentID"].ToString());
return im;
}
示例5: GridInstantMessage
public GridInstantMessage(GridInstantMessage im, bool addTimestamp)
{
fromAgentID = im.fromAgentID;
fromAgentName = im.fromAgentName;
toAgentID = im.toAgentID;
dialog = im.dialog;
fromGroup = im.fromGroup;
message = im.message;
imSessionID = im.imSessionID;
offline = im.offline;
Position = im.Position;
binaryBucket = im.binaryBucket;
RegionID = im.RegionID;
if (addTimestamp)
timestamp = (uint)Util.UnixTimeSinceEpoch();
}
示例6: SendInstantMessage
/// <summary>
/// This actually does the XMLRPC Request
/// </summary>
/// <param name="url">URL we pull the data out of to send the request to</param>
/// <param name="im">The Instant Message </param>
/// <returns>Bool if the message was successfully delivered at the other side.</returns>
public static bool SendInstantMessage(string url, GridInstantMessage im)
{
Hashtable xmlrpcdata = ConvertGridInstantMessageToXMLRPC(im);
xmlrpcdata["region_handle"] = 0;
ArrayList SendParams = new ArrayList();
SendParams.Add(xmlrpcdata);
XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams);
try
{
XmlRpcResponse GridResp = GridReq.Send(url, 10000);
Hashtable responseData = (Hashtable)GridResp.Value;
if (responseData.ContainsKey("success"))
{
if ((string)responseData["success"] == "TRUE")
{
//m_log.DebugFormat("[XXX] Success");
return true;
}
else
{
//m_log.DebugFormat("[XXX] Fail");
return false;
}
}
else
{
m_log.DebugFormat("[GRID INSTANT MESSAGE]: No response from {0}", url);
return false;
}
}
catch (WebException e)
{
m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} the host didn't respond " + e.ToString(), url);
}
return false;
}
示例7: onInstantMessage
private void onInstantMessage(GridInstantMessage msg)
{
if(msg.dialog != 0)
{
return;
}
string sender = msg.fromAgentID.ToString();
string target = msg.toAgentID.ToString();
int isGroup;
if(msg.fromGroup)
{
isGroup = 1;//
}
else
{
isGroup = 0;
}
string body = msg.message;
String message = MGMJson.InstantMessage(sender, target,isGroup,body);
link.send(message);
}
示例8: Main
public static void Main(string[] args)
{
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.Layout =
new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
log4net.Config.BasicConfigurator.Configure(consoleAppender);
string serverURI = "http://127.0.0.1:8002";
GridInstantMessage im = new GridInstantMessage();
im.fromAgentID = new Guid();
im.toAgentID = new Guid();
im.message = "Hello";
im.imSessionID = new Guid();
bool success = InstantMessageServiceConnector.SendInstantMessage(serverURI, im);
if (success)
m_log.InfoFormat("[IM CLIENT]: Successfully IMed {0}", serverURI);
else
m_log.InfoFormat("[IM CLIENT]: failed to IM {0}", serverURI);
System.Console.WriteLine("\n");
}
示例9: StoreMessage
public bool StoreMessage(GridInstantMessage im, out string reason)
{
reason = string.Empty;
// Check limits
UUID principalID = new UUID(im.toAgentID);
long count = m_Database.GetCount("PrincipalID", principalID.ToString());
if (count >= MAX_IM)
{
reason = "Number of offline IMs has maxed out";
return false;
}
string imXml;
using (MemoryStream mstream = new MemoryStream())
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Util.UTF8NoBomEncoding;
using (XmlWriter writer = XmlWriter.Create(mstream, settings))
{
m_serializer.Serialize(writer, im);
writer.Flush();
}
imXml = Util.UTF8NoBomEncoding.GetString(mstream.ToArray());
}
OfflineIMData data = new OfflineIMData();
data.PrincipalID = principalID;
data.FromID = new UUID(im.fromAgentID);
data.Data = new Dictionary<string, string>();
data.Data["Message"] = imXml;
return m_Database.Store(data);
}
示例10: LocalFriendshipApproved
public bool LocalFriendshipApproved(UUID userID, string userName, UUID friendID)
{
IClientAPI friendClient = LocateClientObject(friendID);
if (friendClient != null)
{
// the prospective friend in this sim as root agent
GridInstantMessage im = new GridInstantMessage(Scene, userID, userName, friendID,
(byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero);
friendClient.SendInstantMessage(im);
// update the local cache
m_Friends[friendID].Friends = FriendsService.GetFriends(friendID);
// we're done
return true;
}
return false;
}
示例11: ForwardFriendshipOffer
private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im)
{
// !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID)
// We stick this agent's ID as imSession, so that it's directly available on the receiving end
im.imSessionID = im.fromAgentID;
// Try the local sim
if (LocalFriendshipOffered(friendID, im))
return;
// The prospective friend is not here [as root]. Let's forward.
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
if (friendSession != null)
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message);
}
// If the prospective friend is not online, he'll get the message upon login.
}
示例12: SendFriendsOnlineIfNeeded
public void SendFriendsOnlineIfNeeded(IClientAPI client)
{
UUID agentID = client.AgentId;
if (m_NeedsListOfFriends.Contains(agentID))
{
if (!m_Friends.ContainsKey(agentID))
{
m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID);
return;
}
//
// Send the friends online
//
List<UUID> online = GetOnlineFriends(agentID);
if (online.Count > 0)
{
m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count);
client.SendAgentOnline(online.ToArray());
}
//
// Send outstanding friendship offers
//
if (m_Friends.ContainsKey(agentID))
{
List<string> outstanding = new List<string>();
foreach (FriendInfo fi in m_Friends[agentID].Friends)
if (fi.TheirFlags == -1)
outstanding.Add(fi.Friend);
GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, "", agentID, (byte)InstantMessageDialog.FriendshipOffered, "Will you be my friend?", true, Vector3.Zero);
foreach (string fid in outstanding)
{
try
{
im.fromAgentID = new Guid(fid);
}
catch
{
continue;
}
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, new UUID(im.fromAgentID));
im.fromAgentName = account.FirstName + " " + account.LastName;
PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid });
PresenceInfo presence = PresenceInfo.GetOnlinePresence(presences);
if (presence != null)
im.offline = 0;
im.imSessionID = im.fromAgentID;
// Finally
LocalFriendshipOffered(agentID, im);
}
}
lock (m_NeedsListOfFriends)
m_NeedsListOfFriends.Remove(agentID);
}
}
示例13: OnGridInstantMessage
/// <summary>
///
/// </summary>
/// <param name="msg"></param>
private void OnGridInstantMessage(GridInstantMessage msg)
{
// Just call the Text IM handler above
// This event won't be raised unless we have that agent,
// so we can depend on the above not trying to send
// via grid again
//
OnInstantMessage(null, msg);
}
示例14: TriggerUnhandledInstantMessage
public void TriggerUnhandledInstantMessage(GridInstantMessage message)
{
IncomingInstantMessage handlerUnhandledInstantMessage = OnUnhandledInstantMessage;
if (handlerUnhandledInstantMessage != null)
{
foreach (IncomingInstantMessage d in handlerUnhandledInstantMessage.GetInvocationList())
{
try
{
d(message);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
示例15: SendInstantMessage
public void SendInstantMessage(GridInstantMessage im)
{
}