* Implements Group Chat
* Adds Example TestClient command imgroup * Adds convenience methods to InternalDictionary git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1597 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
|
||||
namespace libsecondlife.TestClient
|
||||
{
|
||||
public class ImGroupCommand : Command
|
||||
{
|
||||
LLUUID ToGroupID = LLUUID.Zero;
|
||||
ManualResetEvent WaitForSessionStart = new ManualResetEvent(false);
|
||||
public ImGroupCommand(TestClient testClient)
|
||||
{
|
||||
|
||||
Name = "imgroup";
|
||||
Description = "Send an instant message to a group. Usage: imgroup [group_uuid] [message]";
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, LLUUID fromAgentID)
|
||||
{
|
||||
if (args.Length < 2)
|
||||
return "Usage: imgroup [group_uuid] [message]";
|
||||
|
||||
|
||||
|
||||
if (LLUUID.TryParse(args[0], out ToGroupID))
|
||||
{
|
||||
string message = String.Empty;
|
||||
for (int ct = 1; ct < args.Length; ct++)
|
||||
message += args[ct] + " ";
|
||||
message = message.TrimEnd();
|
||||
if (message.Length > 1023) message = message.Remove(1023);
|
||||
|
||||
Client.Self.OnGroupChatJoin += new AgentManager.GroupChatJoined(Self_OnGroupChatJoin);
|
||||
Client.Self.RequestJoinGroupChat(ToGroupID);
|
||||
WaitForSessionStart.Reset();
|
||||
if (WaitForSessionStart.WaitOne(10000, false))
|
||||
{
|
||||
Client.Self.InstantMessageGroup(ToGroupID, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Timeout waiting for group session start";
|
||||
}
|
||||
Client.Self.OnGroupChatJoin -= new AgentManager.GroupChatJoined(Self_OnGroupChatJoin);
|
||||
Client.Self.RequestLeaveGroupChat(ToGroupID);
|
||||
return "Instant Messaged group " + ToGroupID.ToString() + " with message: " + message;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "failed to instant message group";
|
||||
}
|
||||
}
|
||||
|
||||
void Self_OnGroupChatJoin(LLUUID groupChatSessionID)
|
||||
{
|
||||
WaitForSessionStart.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,7 @@ namespace libsecondlife.TestClient
|
||||
if (im.FromAgentID != MasterKey)
|
||||
{
|
||||
// Received an IM from someone that is not the bot's master, ignore
|
||||
Console.WriteLine("<IM ({0})> {1} (not master): {2} (@{3}:{4})", im.Dialog, im.FromAgentName, im.Message,
|
||||
Console.WriteLine("<{0} ({1})> {2} (not master): {3} (@{4}:{5})", im.GroupIM ? "GroupIM" : "IM", im.Dialog, im.FromAgentName, im.Message,
|
||||
im.RegionID, im.Position);
|
||||
return;
|
||||
}
|
||||
@@ -204,13 +204,13 @@ namespace libsecondlife.TestClient
|
||||
else if (GroupMembers != null && !GroupMembers.ContainsKey(im.FromAgentID))
|
||||
{
|
||||
// Received an IM from someone outside the bot's group, ignore
|
||||
Console.WriteLine("<IM ({0})> {1} (not in group): {2} (@{3}:{4})", im.Dialog, im.FromAgentName,
|
||||
Console.WriteLine("<{0} ({1})> {2} (not in group): {3} (@{4}:{5})", im.GroupIM ? "GroupIM" : "IM", im.Dialog, im.FromAgentName,
|
||||
im.Message, im.RegionID, im.Position);
|
||||
return;
|
||||
}
|
||||
|
||||
// Received an IM from someone that is authenticated
|
||||
Console.WriteLine("<IM ({0})> {1}: {2} (@{3}:{4})", im.Dialog, im.FromAgentName, im.Message, im.RegionID, im.Position);
|
||||
Console.WriteLine("<{0} ({1})> {2}: {3} (@{4}:{5})", im.GroupIM ? "GroupIM" : "IM", im.Dialog, im.FromAgentName, im.Message, im.RegionID, im.Position);
|
||||
|
||||
if (im.Dialog == InstantMessageDialog.RequestTeleport)
|
||||
{
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<Compile Include="Commands\CloneProfileCommand.cs" />
|
||||
<Compile Include="Commands\Communication\EchoMasterCommand.cs" />
|
||||
<Compile Include="Commands\Communication\IMCommand.cs" />
|
||||
<Compile Include="Commands\Communication\IMGroupCommand.cs" />
|
||||
<Compile Include="Commands\Communication\SayCommand.cs" />
|
||||
<Compile Include="Commands\Communication\ShoutCommand.cs" />
|
||||
<Compile Include="Commands\Communication\WhisperCommand.cs" />
|
||||
|
||||
Reference in New Issue
Block a user