public bool OnNewChatMessageFromWorld(OSChatMessage c, out OSChatMessage newc) { 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, c.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, c.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, c.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, c.Scene, c.Position); } } newc = c; //Block the message from going to everyone, only the server needed to hear return true; }
public OSChatMessage Copy() { OSChatMessage message = new OSChatMessage { Channel = Channel, From = From, Message = Message, Position = Position, Range = Range, Scene = Scene, Sender = Sender, SenderObject = SenderObject, SenderUUID = SenderUUID, Type = Type, ToAgentID = ToAgentID }; return message; }
void OnStartupComplete(IScene scene, List<string> data) { int num = 0; while (num < data.Count - 1) { string type = data[num].ToString(); int len = Convert.ToInt32(data[num + 1]); num += 2; if (type == "ScriptEngine") { if (m_firstEmptyCompileQueue || m_oarFileLoading) { OSChatMessage c = new OSChatMessage(); if (m_firstEmptyCompileQueue) c.Message = "server_startup,"; else c.Message = "oar_file_load,"; m_firstEmptyCompileQueue = false; m_oarFileLoading = false; c.From = "RegionReady"; if (m_lastOarLoadedOk) c.Message += "1,"; else c.Message += "0,"; c.Channel = m_channelNotify; //Equiv of 'c.Message += numScriptsFailed.ToString() + "," + message;' c.Message += data[num] + "," + data[num+1]; c.Type = ChatTypeEnum.Region; c.Position = new Vector3((m_scene.RegionInfo.RegionSizeX * 0.5f), (m_scene.RegionInfo.RegionSizeY * 0.5f), 30); c.Sender = null; c.SenderUUID = UUID.Zero; c.Scene = m_scene; MainConsole.Instance.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}", m_scene.RegionInfo.RegionName, c.Message, m_channelNotify); m_scene.EventManager.TriggerOnChatBroadcast(this, c); } } else num += len; } }
void EventManager_OnChatFromClient(IClientAPI sender, OSChatMessage chat) { if(chat.Message == "" || sender == null || chat.Channel != m_chatToIRCChannel) return; Client client; if(TryGetClient(sender.AgentId, out client)) { Util.FireAndForget(delegate(object o) { client.SendChat("(grid: " + MainServer.Instance.ServerURI.Remove(0, 7) + ") - " + chat.Message, m_channel); }); } }
private void HandleChatPacket(OSChatMessage chat) { if (string.IsNullOrEmpty(chat.Message)) return; // Object? if (chat.Sender == null && chat.SenderObject != null) { ChatEventArgs e = new ChatEventArgs { Sender = new SOPObject(m_internalScene, chat.SenderObject.LocalId, m_security), Text = chat.Message, Channel = chat.Channel }; _OnChat(this, e); return; } // Avatar? if (chat.Sender != null && chat.SenderObject == null) { ChatEventArgs e = new ChatEventArgs { Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security), Text = chat.Message, Channel = chat.Channel }; _OnChat(this, e); return; } // Skip if other }
protected void AnnounceToAgent(IScenePresence agent, string msg) { OSChatMessage c = new OSChatMessage(); c.Message = msg; c.Type = ChatTypeEnum.Say; c.Channel = 0; c.Position = PosOfGod; c.From = m_whoami; c.Sender = null; c.SenderUUID = UUID.Zero; c.Scene = agent.Scene; agent.ControllingClient.SendChatMessage(msg, (byte) ChatTypeEnum.Say, PosOfGod, m_whoami, UUID.Zero, (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully); }
protected virtual void OnChatBroadcast(Object sender, OSChatMessage c) { // unless the chat to be broadcast is of type Region, we // drop it if its channel is neither 0 nor DEBUG_CHANNEL if (c.Channel != DEFAULT_CHANNEL && c.Channel != DEBUG_CHANNEL && c.Type != ChatTypeEnum.Region) return; ChatTypeEnum cType = c.Type; if (c.Channel == DEBUG_CHANNEL) cType = ChatTypeEnum.DebugChannel; if (c.Range > m_maxChatDistance) c.Range = m_maxChatDistance; if (cType == ChatTypeEnum.SayTo) //Change to something client can understand as SayTo doesn't exist except on the server cType = ChatTypeEnum.Owner; if (cType == ChatTypeEnum.Region) cType = ChatTypeEnum.Say; if (c.Message.Length > 1100) c.Message = c.Message.Substring(0, 1000); // broadcast chat works by redistributing every incoming chat // message to each avatar in the scene. string fromName = c.From; UUID fromID = UUID.Zero; ChatSourceType sourceType = ChatSourceType.Object; if (null != c.Sender) { IScenePresence avatar = c.Scene.GetScenePresence(c.Sender.AgentId); fromID = c.Sender.AgentId; fromName = avatar.Name; sourceType = ChatSourceType.Agent; } // MainConsole.Instance.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); c.Scene.ForEachScenePresence( delegate(IScenePresence presence) { // ignore chat from child agents if (presence.IsChildAgent) return; IClientAPI client = presence.ControllingClient; // don't forward SayOwner chat from objects to // non-owner agents if ((c.Type == ChatTypeEnum.Owner) && (null != c.SenderObject) && (c.SenderObject.OwnerID != client.AgentId)) return; // don't forward SayTo chat from objects to // non-targeted agents if ((c.Type == ChatTypeEnum.SayTo) && (c.ToAgentID != client.AgentId)) return; bool cached = false; MuteList[] mutes = GetMutes(client.AgentId, out cached); foreach (MuteList m in mutes) if (m.MuteID == c.SenderUUID || (c.SenderObject != null && m.MuteID == c.SenderObject.ParentEntity.UUID)) return; client.SendChatMessage(c.Message, (byte) cType, new Vector3(client.Scene.RegionInfo.RegionSizeX*0.5f, client.Scene.RegionInfo.RegionSizeY*0.5f, 30), fromName, fromID, (byte) sourceType, (byte) ChatAudibleLevel.Fully); }); }
public void SimChat(string message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent, bool broadcast, float range, UUID ToAgentID, IScene scene) { OSChatMessage args = new OSChatMessage { Message = message, Channel = channel, Type = type, Position = fromPos, Range = range, SenderUUID = fromID, Scene = scene, ToAgentID = ToAgentID }; if (fromAgent) { IScenePresence user = scene.GetScenePresence(fromID); if (user != null) args.Sender = user.ControllingClient; } else { args.SenderObject = scene.GetSceneObjectPart(fromID); } args.From = fromName; //args. if (broadcast) { OnChatBroadcast(scene, args); scene.EventManager.TriggerOnChatBroadcast(scene, args); } else { OnChatFromWorld(scene, args); scene.EventManager.TriggerOnChatFromWorld(scene, args); } }
public bool OnNewChatMessageFromWorld(OSChatMessage c, out OSChatMessage newc) { IScenePresence SP = c.Scene.GetScenePresence(c.SenderUUID); if (SP != null) { if (!SP.IsChildAgent) { //Check that the agent is allows to speak in this reigon if (SP.GodLevel != 0 && !!m_authorizedSpeakers.Contains(c.SenderUUID)) m_authorizedSpeakers.Add(c.SenderUUID); if (SP.GodLevel != 0 && !m_authList.Contains(c.SenderUUID)) m_authList.Add(c.SenderUUID); if (!m_authorizedSpeakers.Contains(c.SenderUUID)) { newc = c; //They can't talk, so block it return false; } } } if (c.Message.Contains("Chat.")) { if (!m_useAuth || m_authList.Contains(c.SenderUUID)) { IScenePresence senderSP; c.Scene.TryGetScenePresence(c.SenderUUID, out senderSP); string[] message = c.Message.Split('.'); if (message[1] == "SayDistance") { chatModule.SayDistance = Convert.ToInt32(message[2]); chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, message[1] + " changed.", ChatSourceType.System, -1); } if (message[1] == "WhisperDistance") { chatModule.WhisperDistance = Convert.ToInt32(message[2]); chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, message[1] + " changed.", ChatSourceType.System, -1); } if (message[1] == "ShoutDistance") { chatModule.ShoutDistance = Convert.ToInt32(message[2]); chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, message[1] + " changed.", ChatSourceType.System, -1); } //Add the user to the list of allowed speakers and 'chat' admins if (message[1] == "AddToAuth") { IScenePresence NewSP; c.Scene.TryGetAvatarByName(message[2], out NewSP); m_authList.Add(NewSP.UUID); chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, message[2] + " added.", ChatSourceType.System, -1); } if (message[1] == "RemoveFromAuth") { IScenePresence NewSP; c.Scene.TryGetAvatarByName(message[2], out NewSP); m_authList.Remove(NewSP.UUID); chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, message[2] + " added.", ChatSourceType.System, -1); } //Block chat from those not in the auth list if (message[1] == "BlockChat") { m_blockChat = true; chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, "Chat blocked.", ChatSourceType.System, -1); } //Allow chat from all again if (message[1] == "AllowChat") { m_blockChat = false; chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, "Chat allowed.", ChatSourceType.System, -1); } //Remove speaking priviledges from an individual if (message[1] == "RevokeSpeakingRights") { IScenePresence NewSP; c.Scene.TryGetAvatarByName(message[2], out NewSP); m_authorizedSpeakers.Remove(NewSP.UUID); chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, message[2] + " - revoked.", ChatSourceType.System, -1); } //Allow an individual to speak again if (message[1] == "GiveSpeakingRights") { IScenePresence NewSP; c.Scene.TryGetAvatarByName(message[2], out NewSP); m_authorizedSpeakers.Add(NewSP.UUID); chatModule.TrySendChatMessage(senderSP, c.Position, new Vector3(c.Scene.RegionInfo.RegionLocX, c.Scene.RegionInfo.RegionLocY, 0), UUID.Zero, "AuroraChat", ChatTypeEnum.Region, message[2] + " - revoked.", ChatSourceType.System, -1); } } newc = c; //Block commands from normal chat return false; } if (SP != null) { //Add the god prefix if (SP.GodLevel != 0 && m_indicategod) c.Message = m_godPrefix + c.Message; } newc = c; return true; }
/// <summary> /// Tell the client what the result is /// </summary> /// <param name="result"></param> /// <param name="scene"></param> /// <param name="position"></param> private void BuildAndSendResult(float result, IScene scene, Vector3 position) { OSChatMessage message = new OSChatMessage { From = "Server", Message = "Result: " + result, Channel = 0, Type = ChatTypeEnum.Region, Position = position, Sender = null, SenderUUID = UUID.Zero, Scene = scene }; scene.EventManager.TriggerOnChatBroadcast(null, message); }
private void DeliverClientMessage(Object sender, OSChatMessage e) { if (null != e.Sender) DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position, -1, UUID.Zero); else DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position, -1, UUID.Zero); }
void EventManager_OnChatFromClient(IClientAPI sender, OSChatMessage chat) { if (chat.Message == "" || sender == null || chat.Channel != m_chatToIRCChannel) return; Client client; if(TryGetClient(sender.AgentId, out client)) { Util.FireAndForget(delegate(object o) { IScenePresence sp = sender.Scene.GetScenePresence(sender.AgentId); if (sp != null) { string channel; if (m_channel.TryGetValue(sp.CurrentParcel.LandData.GlobalID, out channel)) { client.SendChat("(grid: " + MainServer.Instance.ServerURI.Remove(0, 7) + ") - " + chat.Message, channel); } } }); } }
protected override void OnChatFromClient(IClientAPI sender, OSChatMessage c) { if (m_replacingChatModule) { // replacing ChatModule: need to redistribute // ChatFromClient to interested subscribers c = FixPositionOfChatMessage(c); IScene scene = c.Scene; scene.EventManager.TriggerOnChatFromClient(sender, c); // when we are replacing ChatModule, we treat // OnChatFromClient like OnChatBroadcast for // concierged regions, effectively extending the // range of chat to cover the whole // region. however, we don't do this for whisper // (got to have some privacy) if (c.Type != ChatTypeEnum.Whisper) { base.OnChatBroadcast(sender, c); return; } // redistribution will be done by base class base.OnChatFromClient(sender, c); } // TODO: capture chat return; }
protected override void OnChatBroadcast(Object sender, OSChatMessage c) { if (m_replacingChatModule) { // distribute chat message to each and every avatar in // the region base.OnChatBroadcast(sender, c); } // TODO: capture logic return; }
// protected void AnnounceToAgentsRegion(Scene scene, string msg) // { // ScenePresence agent = null; // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent)) // AnnounceToAgentsRegion(agent, msg); // else // MainConsole.Instance.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name); // } protected void AnnounceToAgentsRegion(IScene scene, string msg) { OSChatMessage c = new OSChatMessage(); c.Message = msg; c.Type = ChatTypeEnum.Say; c.Channel = 0; c.Position = PosOfGod; c.From = m_whoami; c.Sender = null; c.SenderUUID = UUID.Zero; c.Scene = scene; scene.EventManager.TriggerOnChatBroadcast(this, c); }
public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) { string fromName = c.From; UUID fromID = UUID.Zero; string message = c.Message; IScene scene = c.Scene; Vector3 fromPos = c.Position; if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; IScenePresence avatar = (scene != null && c.Sender != null) ? scene.GetScenePresence(c.Sender.AgentId) : null; switch (sourceType) { case ChatSourceType.Agent: if (scene != null) { if (avatar != null && message == "") { fromPos = avatar.AbsolutePosition; fromName = avatar.Name; fromID = c.Sender.AgentId; //Always send this so it fires on typing start and end IAttachmentsModule attMod = scene.RequestModuleInterface<IAttachmentsModule>(); if (attMod != null) attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object[] {Changed.STATE}); } else fromID = c.SenderUUID; } else fromID = c.SenderUUID; break; case ChatSourceType.Object: fromID = c.SenderUUID; break; } if (message.Length >= 1000) // libomv limit message = message.Substring(0, 1000); foreach (IScenePresence presence in from presence in m_Scene.GetScenePresences() where !presence.IsChildAgent let fromRegionPos = fromPos let toRegionPos = presence.AbsolutePosition let dis = (int) Util.GetDistanceTo(toRegionPos, fromRegionPos) where (c.Type != ChatTypeEnum.Whisper || dis <= m_whisperdistance) && (c.Type != ChatTypeEnum.Say || dis <= m_saydistance) && (c.Type != ChatTypeEnum.Shout || dis <= m_shoutdistance) && (c.Type != ChatTypeEnum.Custom || dis <= c.Range) where sourceType != ChatSourceType.Agent || avatar == null || avatar.CurrentParcel == null || (avatar.CurrentParcelUUID == presence.CurrentParcelUUID || (!avatar.CurrentParcel.LandData.Private && !presence.CurrentParcel.LandData.Private)) select presence) { //If one of them is in a private parcel, and the other isn't in the same parcel, don't send the chat message TrySendChatMessage(presence, fromPos, fromID, fromName, c.Type, message, sourceType, c.Range); } }
/// <summary> /// Send the message from the prim to the avatars in the regions /// </summary> /// <param name="sender"></param> /// <param name="c"></param> public virtual void OnChatFromWorld(Object sender, OSChatMessage c) { // early return if not on public or debug channel if (c.Channel != DEFAULT_CHANNEL && c.Channel != DEBUG_CHANNEL) return; if (c.Range > m_maxChatDistance) //Check for max distance c.Range = m_maxChatDistance; DeliverChatToAvatars(ChatSourceType.Object, c); }
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) { MainConsole.Instance.ErrorFormat( "[EVENT MANAGER]: Delegate for TriggerOnChatFromClient failed - continuing. {0} {1}", e, e.StackTrace); } } } }
/// <summary> /// Set the correct position for the chat message /// </summary> /// <param name="c"></param> /// <returns></returns> protected OSChatMessage FixPositionOfChatMessage(OSChatMessage c) { IScenePresence avatar; if ((avatar = c.Scene.GetScenePresence(c.Sender.AgentId)) != null) c.Position = avatar.AbsolutePosition; return c; }
private void EventManager_OnChatFromWorld(object sender, OSChatMessage chat) { if (_OnChat != null) { HandleChatPacket(chat); return; } }
/// <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 != "") { 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; } } string Name2 = ""; if (sender is IClientAPI) { Name2 = (sender).Name; } c.From = Name2; DeliverChatToAvatars(ChatSourceType.Agent, c); }
public override void OnChatFromWorld(Object sender, OSChatMessage c) { if (m_replacingChatModule) { // when we are replacing ChatModule, we treat // OnChatFromClient like OnChatBroadcast for // concierged regions, effectively extending the // range of chat to cover the whole // region. however, we don't do this for whisper // (got to have some privacy) if (c.Type != ChatTypeEnum.Whisper) { base.OnChatBroadcast(sender, c); return; } base.OnChatFromWorld(sender, c); } return; }