本文整理汇总了C#中OpenSim.Framework.OSChatMessage类的典型用法代码示例。如果您正苦于以下问题:C# OSChatMessage类的具体用法?C# OSChatMessage怎么用?C# OSChatMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OSChatMessage类属于OpenSim.Framework命名空间,在下文中一共展示了OSChatMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
//List<Chatbag> doclist;
//doclist = ConfigParser.Parse("chatbag.xml", "chatbag.xsd");
//Console.Out.WriteLine("Config parsing successful");
ChatHandler.Instance.RegisterCommand(
new ChatHandler.ChatCommand(0, "hello|hi|what's up_world",
delegate(ChatHandler.MatchContainer match) { })
);
ChatHandler.Instance.RegisterField("curse", "(?:frickin[g]?|fuckin[g]?)");
ChatHandler.Instance.RegisterCommand(
new ChatHandler.ChatCommand(0, "{curse}",
delegate(ChatHandler.MatchContainer match) { })
);
string[] phrases = {"What's up frickin world, what's up?", "Hello fucking world?"};
foreach( string phrase in phrases ){
OSChatMessage msg = new OSChatMessage();
msg.Message = phrase;
msg.Channel = 0;
List<ChatHandler.MatchContainer> matches = ChatHandler.Instance.DetectCommand2(msg);
foreach( ChatHandler.MatchContainer match in matches ){
Console.Out.WriteLine(string.Format(
"Command '{0}' found in '{1}' ({2})",
match.Command.Phrase, match.MatchedMessage.Message, String.Join<string>("_", match.MatchedWording) ));
}
}
Console.Out.WriteLine("Match list complete");
Console.Out.WriteLine("Tests completed successfully.");
Console.Read();
}
示例2: OnChatFromWorld
private void OnChatFromWorld(object sender, OSChatMessage oscm)
{
// Console.WriteLine("Got chat [{0}]", oscm.Message);
// m_osChatMessageReceived = oscm;
m_chatEvent.Set();
}
示例3: SimChat
protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
UUID fromID, bool fromAgent, bool broadcast)
{
OSChatMessage args = new OSChatMessage();
args.Message = Utils.BytesToString(message);
args.Channel = channel;
args.Type = type;
args.Position = fromPos;
args.SenderUUID = fromID;
args.Scene = this;
if (fromAgent)
{
ScenePresence user = GetScenePresence(fromID);
if (user != null)
args.Sender = user.ControllingClient;
}
else
{
SceneObjectPart obj = GetSceneObjectPart(fromID);
args.SenderObject = obj;
}
args.From = fromName;
//args.
if (broadcast)
EventManager.TriggerOnChatBroadcast(this, args);
else
EventManager.TriggerOnChatFromWorld(this, args);
}
示例4: BuildAndSendResult
private void BuildAndSendResult(float result, Scene scene, Vector3 position)
{
OSChatMessage message = new OSChatMessage();
message.From = "Server";
message.Message = "Result: " + result;
message.Channel = 0;
message.Type = ChatTypeEnum.Region;
message.Position = position;
message.Sender = null;
message.SenderUUID = UUID.Zero;
message.Scene = scene;
scene.EventManager.TriggerOnChatBroadcast(null, message);
}
示例5: OnNewChatMessageFromWorld
public bool OnNewChatMessageFromWorld(OSChatMessage c, out OSChatMessage newc)
{
Scene scene = (Scene)c.Scene;
string[] operators = c.Message.Split(' ');
if (operators[0] == "calc.Add")
{
if (operators.Length == 3)
{
float Num1 = float.Parse(operators[1]);
float Num2 = float.Parse(operators[2]);
float RetVal = Num1 + Num2;
BuildAndSendResult(RetVal, scene, c.Position);
}
}
if (operators[0] == "calc.Subtract")
{
if (operators.Length == 3)
{
float Num1 = float.Parse(operators[1]);
float Num2 = float.Parse(operators[2]);
float RetVal = Num1 - Num2;
BuildAndSendResult(RetVal, scene, c.Position);
}
}
if (operators[0] == "calc.Multiply")
{
if (operators.Length == 3)
{
float Num1 = float.Parse(operators[1]);
float Num2 = float.Parse(operators[2]);
float RetVal = Num1 * Num2;
BuildAndSendResult(RetVal, scene, c.Position);
}
}
if (operators[0] == "calc.Divide")
{
if (operators.Length == 3)
{
float Num1 = float.Parse(operators[1]);
float Num2 = float.Parse(operators[2]);
float RetVal = Num1 / Num2;
BuildAndSendResult(RetVal, scene, c.Position);
}
}
newc = c;
//Block the message from going to everyone, only the server needed to hear
return true;
}
示例6: Copy
public OSChatMessage Copy()
{
OSChatMessage message = new OSChatMessage();
message.Channel = Channel;
message.From = From;
message.Message = Message;
message.Position = Position;
message.Range = Range;
message.Scene = Scene;
message.Sender = Sender;
message.SenderObject = SenderObject;
message.SenderUUID = SenderUUID;
message.Type = Type;
message.ToAgentID = ToAgentID;
return message;
}
示例7: SimChat
/// <summary>
/// Send chat to listeners.
/// </summary>
/// <param name='message'></param>
/// <param name='type'>/param>
/// <param name='channel'></param>
/// <param name='fromPos'></param>
/// <param name='fromName'></param>
/// <param name='fromID'></param>
/// <param name='targetID'></param>
/// <param name='fromAgent'></param>
/// <param name='broadcast'></param>
public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
{
OSChatMessage args = new OSChatMessage();
args.Message = Utils.BytesToString(message);
args.Channel = channel;
args.Type = type;
args.Position = fromPos;
args.SenderUUID = fromID;
args.Scene = this;
args.Destination = targetID;
if (fromAgent)
{
ScenePresence user = GetScenePresence(fromID);
if (user != null)
args.Sender = user.ControllingClient;
}
else
{
SceneObjectPart obj = GetSceneObjectPart(fromID);
args.SenderObject = obj;
}
args.From = fromName;
//args.
// m_log.DebugFormat(
// "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}",
// args.Message.Replace("\n", "\\n"), args.Channel, args.Type, fromName, broadcast);
if (broadcast)
EventManager.TriggerOnChatBroadcast(this, args);
else
EventManager.TriggerOnChatFromWorld(this, args);
}
示例8: SendChatMessageToNeighbors
public bool SendChatMessageToNeighbors(OSChatMessage message, ChatSourceType type, RegionInfo region)
{
bool RetVal = false;
if (!m_KnownNeighbors.ContainsKey(region.RegionID))
return RetVal;
foreach (GridRegion neighbor in m_KnownNeighbors[region.RegionID])
{
if (neighbor.RegionID == region.RegionID)
continue;
Scene scene = FindSceneByUUID(region.RegionID);
if (scene != null)
{
IChatModule chatModule = scene.RequestModuleInterface<IChatModule>();
if (chatModule != null && !RetVal)
{
chatModule.DeliverChatToAvatars(type, message);
RetVal = true;
}
}
}
return RetVal;
}
示例9: ProcessCustomerReply
protected void ProcessCustomerReply(OSChatMessage chat)
{
bool accepted = false;
if (YES_OPTION == chat.Message)
{
if (m_targetPlayer.Money >= m_salePrice)
accepted = true;
else
SendAlert(m_targetPlayer.Uuid, "You don't have enough money to accept that offer!");
}
if (accepted)
{
m_controller.State.SellWater(m_player, m_targetPlayer, m_waterToSell, m_salePrice);
SendAlert(
m_player,
string.Format(
"You successfully leased {0} units of water to {1} for {2}{3}",
m_waterToSell, m_targetPlayer.Name, WaterWarsConstants.MONEY_UNIT, m_salePrice));
SendAlert(
m_targetPlayer,
string.Format(
"You successfully leased {0} units of water from {1} for {2}{3}",
m_waterToSell, m_player.Name, WaterWarsConstants.MONEY_UNIT, m_salePrice));
}
else
{
m_controller.EventManager.TriggerWaterSold(
m_targetPlayer, m_player, m_waterToSell, m_salePrice, false);
SendAlert(
m_player,
string.Format(
"{0} declined your offer to lease them {1} units of water for {2}{3}",
m_targetPlayer.Name, m_waterToSell, WaterWarsConstants.MONEY_UNIT, m_salePrice));
}
}
示例10: TriggerOnChatFromClient
public void TriggerOnChatFromClient (IClientAPI sender, OSChatMessage chat)
{
ChatFromClientEvent handlerChatFromClient = OnChatFromClient;
if (handlerChatFromClient != null)
{
foreach (ChatFromClientEvent d in handlerChatFromClient.GetInvocationList ())
{
try
{
d (sender, chat);
}
catch (Exception e)
{
m_log.ErrorFormat (
"[EVENT MANAGER]: Delegate for TriggerOnChatFromClient failed - continuing. {0} {1}",
e.ToString (), e.StackTrace);
}
}
}
}
示例11: BroadcastSim
public void BroadcastSim(string sender, string format, params string[] args)
{
try
{
OSChatMessage c = new OSChatMessage();
c.From = sender;
c.Message = String.Format(format, args);
c.Type = ChatTypeEnum.Region; // ChatTypeEnum.Say;
c.Position = CenterOfRegion;
c.Sender = null;
c.SenderUUID = UUID.Zero;
ChannelState.OSChat(this, c, true);
}
catch (Exception ex) // IRC gate should not crash Sim
{
m_log.ErrorFormat("[IRC-Connector-{0}]: BroadcastSim Exception Trap: {1}\n{2}", idn, ex.Message, ex.StackTrace);
}
}
示例12: OnChatFromClient
private void OnChatFromClient(object sender, OSChatMessage msg)
{
if (msg.Sender == null)
return;
//m_log.DebugFormat("chan {0} msg {1}", msg.Channel, msg.Message);
IClientAPI client = msg.Sender;
if (!m_floaters.ContainsKey(client.AgentId))
return;
string[] parts = msg.Message.Split(new char[] {':'});
if (parts.Length == 0)
return;
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null || sp.IsChildAgent)
return;
Dictionary<int, FloaterData> d = m_floaters[client.AgentId];
// Work around a viewer bug - VALUE from any
// dialog can appear on this channel and needs to
// be dispatched to ALL open dialogs for the user
if (msg.Channel == 427169570)
{
if (parts[0] == "VALUE")
{
foreach (FloaterData dd in d.Values)
{
if(dd.Handler(client, dd, parts))
{
m_floaters[client.AgentId].Remove(dd.Channel);
SendToClient(sp, String.Format("># floater {0} destroy", dd.FloaterName));
break;
}
}
}
return;
}
if (!d.ContainsKey(msg.Channel))
return;
FloaterData data = d[msg.Channel];
if (parts[0] == "NOTIFY")
{
if (parts[1] == "cancel" || parts[1] == data.FloaterName)
{
m_floaters[client.AgentId].Remove(data.Channel);
SendToClient(sp, String.Format("># floater {0} destroy", data.FloaterName));
}
}
if (data.Handler != null && data.Handler(client, data, parts))
{
m_floaters[client.AgentId].Remove(data.Channel);
SendToClient(sp, String.Format("># floater {0} destroy", data.FloaterName));
}
}
示例13: OSChat
// This method gives the region an opportunity to interfere with
// message delivery. For now we just enforce the enable/disable
// flag.
internal void OSChat(Object irc, OSChatMessage msg)
{
if (enabled)
{
// m_log.DebugFormat("[IRC-OSCHAT] Region {0} being sent message", region.Region);
msg.Scene = scene;
scene.EventManager.TriggerOnChatBroadcast(irc, msg);
}
}
示例14: OnSimChat
// This handler detects chat events int he virtual world.
public void OnSimChat(Object sender, OSChatMessage msg)
{
// early return if this comes from the IRC forwarder
if (cs.irc.Equals(sender)) return;
// early return if nothing to forward
if (msg.Message.Length == 0) return;
// check for commands coming from avatars or in-world
// object (if commands are enabled)
if (cs.CommandsEnabled && msg.Channel == cs.CommandChannel)
{
m_log.DebugFormat("[IRC-Region {0}] command on channel {1}: {2}", Region, msg.Channel, msg.Message);
string[] messages = msg.Message.Split(' ');
string command = messages[0].ToLower();
try
{
switch (command)
{
// These commands potentially require a change in the
// underlying ChannelState.
case "server":
cs.Close(this);
cs = cs.UpdateServer(this, messages[1]);
cs.Open(this);
break;
case "port":
cs.Close(this);
cs = cs.UpdatePort(this, messages[1]);
cs.Open(this);
break;
case "channel":
cs.Close(this);
cs = cs.UpdateChannel(this, messages[1]);
cs.Open(this);
break;
case "nick":
cs.Close(this);
cs = cs.UpdateNickname(this, messages[1]);
cs.Open(this);
break;
// These may also (but are less likely) to require a
// change in ChannelState.
case "client-reporting":
cs = cs.UpdateClientReporting(this, messages[1]);
break;
case "in-channel":
cs = cs.UpdateRelayIn(this, messages[1]);
break;
case "out-channel":
cs = cs.UpdateRelayOut(this, messages[1]);
break;
// These are all taken to be temporary changes in state
// so the underlying connector remains intact. But note
// that with regions sharing a connector, there could
// be interference.
case "close":
enabled = false;
cs.Close(this);
break;
case "connect":
enabled = true;
cs.Open(this);
break;
case "reconnect":
enabled = true;
cs.Close(this);
cs.Open(this);
break;
// This one is harmless as far as we can judge from here.
// If it is not, then the complaints will eventually make
// that evident.
default:
m_log.DebugFormat("[IRC-Region {0}] Forwarding unrecognized command to IRC : {1}",
Region, msg.Message);
cs.irc.Send(msg.Message);
break;
}
}
catch (Exception ex)
{
//.........这里部分代码省略.........
示例15: OnChatFromClient
/// <summary>
/// New chat message from the client
/// </summary>
/// <param name = "sender"></param>
/// <param name = "c"></param>
protected virtual void OnChatFromClient(IClientAPI sender, OSChatMessage c)
{
c = FixPositionOfChatMessage(c);
// redistribute to interested subscribers
if(c.Message != "")
c.Scene.EventManager.TriggerOnChatFromClient(sender, c);
// early return if not on public or debug channel
if (c.Channel != DEFAULT_CHANNEL && c.Channel != DEBUG_CHANNEL) return;
// sanity check:
if (c.Sender == null)
{
MainConsole.Instance.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender);
return;
}
//If the message is not blank, tell the plugins about it
if (c.Message != "")
{
#if (!ISWIN)
foreach (string pluginMain in ChatPlugins.Keys)
{
if (pluginMain == "all" || c.Message.StartsWith(pluginMain + "."))
{
IChatPlugin plugin;
ChatPlugins.TryGetValue(pluginMain, out plugin);
//If it returns false, stop the message from being sent
if (!plugin.OnNewChatMessageFromWorld(c, out c))
return;
}
}
#else
foreach (string pluginMain in ChatPlugins.Keys.Where(pluginMain => pluginMain == "all" || c.Message.StartsWith(pluginMain + ".")))
{
IChatPlugin plugin;
ChatPlugins.TryGetValue(pluginMain, out plugin);
//If it returns false, stop the message from being sent
if (!plugin.OnNewChatMessageFromWorld(c, out c))
return;
}
#endif
}
string Name2 = "";
if (sender is IClientAPI)
{
Name2 = (sender).Name;
}
c.From = Name2;
DeliverChatToAvatars(ChatSourceType.Agent, c);
}