private void EntityChatHandler(object sender, ChatArgs e) { if (e.Source is IScenePresence) { int startParam = e.Message.IndexOf('('); int endParam = e.Message.IndexOf(')'); if (startParam > 2 && endParam > startParam) { // Try and parse this into a function call string name = e.Message.Substring(0, startParam); ApiMethod apiMethod; if (m_scene.TryGetApiMethod(name, out apiMethod)) { // Parse the parameters ++startParam; List <string> parameters = ParseParameters(e.Message.Substring(startParam, endParam - startParam)); // Parameters sanity check ParameterInfo[] parameterInfos = apiMethod.MethodInfo.GetParameters(); if (parameters != null && parameters.Count == parameterInfos.Length - 1) { // Convert the parameters into the required types object[] objParameters = ConvertParameters(parameterInfos, parameters); if (objParameters != null) { object ret = m_scriptInstance.CallMethod(name, objParameters); } } } } } }
private void rtbMessage_KeyDown(object sender, KeyEventArgs e) { // Check if user pressed the Enter key. If Enter key was pressed // clear contents of type box and transfer it to top chat box. if (e.KeyCode == Keys.Enter && e.Control == bMessageHotKeyMod) { // We do not want the enter key press to be part of the chat // text, so it is suppressed. e.SuppressKeyPress = true; lastTypeTime = DateTime.MinValue; SendMessage(); rtbMessage.Focus(); } else { TimeSpan timeSpan = DateTime.Now.Subtract(lastTypeTime); // Raise event only if the last event was triggered more than 4 seconds ago. if (timeSpan.TotalSeconds > 4) { lastTypeTime = DateTime.Now; if (Sending != null) { ChatArgs chatArgs = new ChatArgs(DatagramTypes.UserAction, key, UserActions.Typing.GetStringValue()); Sending(this, chatArgs); } } } }
/// <summary> /// Sends the current typed message by invoking the SendHandler event, /// adds it to the chat history box, then clears the message type box. /// </summary> private void SendMessage() { if (bEnabled == false) { return; } rtbMessage.Enabled = false; string rtfText = FormatMessage(); // Send message only if its not empty. if (rtfText.Equals(string.Empty)) { rtbMessage.Enabled = true; return; } ChatArgs e = new ChatArgs(DatagramTypes.Message, key, rtfText); Sending(this, e); // Add the message to the chat history box. DateTime messageTimeStamp = DateTime.UtcNow; string timeStamp = messageTimeStamp.ToBinary().ToString(); AddMessage(timeStamp, localUserName, rtfText); rtbMessage.Clear(); rtbMessage.Enabled = true; }
public void ReceiveAddedMessageNotification(object sender, ChatArgs chatArgs) { if (chatArgs.Message == "cat") { _mediator.RemoveFromChat(chatArgs.ChatMember); SendMessage("Word cat is forbiden"); } }
private void TextBox_DragDrop(object sender, DragEventArgs e) { string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string fileName in fileNames) { ChatArgs chatArgs = new ChatArgs(DatagramTypes.File, key, fileName); Sending(this, chatArgs); break; } }
private void Server_OnServerChatMessage(object sender, ChatArgs e) { /*Debug.WriteLine($"{e.Type.ToString()}"); * if (e.Type == ChatType.CHAT_TYPE_SYSTEM) * return; * * this.Invoke(new Action((s, et) => { })); * * Debug.WriteLine($"{e.Name} : {e.Message}");*/ this.Invoke(MyDelegate, $"{e.Name}: {e.Message}"); }
private void tbChat_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { switch (e.Button.Name) { case "tbBtnFont": fontDialog.Font = rtbMessage.Font; fontDialog.Color = rtbMessage.ForeColor; if (fontDialog.ShowDialog() == DialogResult.OK) { rtbMessage.Font = fontDialog.Font; rtbMessage.ForeColor = fontDialog.Color; } break; case "tbBtnSmiley": tbBtnSmiley.Pushed = true; Point pos = new Point(tbBtnSmiley.Rectangle.Left, tbBtnSmiley.Rectangle.Bottom); mnuSmiley.Show(tbChat, pos, tbBtnSmiley.Rectangle); tbBtnSmiley.Pushed = false; break; case "tbBtnSave": saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); saveFileDialog.FileName = string.Empty; if (saveFileDialog.ShowDialog() == DialogResult.OK) { rtbMessageHistory.SaveFile(saveFileDialog.FileName); } break; case "tbBtnSendFile": //openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); openFileDialog.FileName = string.Empty; if (openFileDialog.ShowDialog() == DialogResult.OK) { ChatArgs chatArgs = new ChatArgs(DatagramTypes.File, key, openFileDialog.FileName); Sending(this, chatArgs); } break; case "tbBtnPop": WindowModeEvents windowEvent = bWindowed ? WindowModeEvents.PopIn : WindowModeEvents.PopOut; WindowModeArgs windowModeArgs = new WindowModeArgs(key, windowEvent); tbChat.ShowToolTips = false; tbPop.ShowToolTips = false; WindowModeChange(this, windowModeArgs); break; } rtbMessage.Focus(); }
void m_scene_OnEntityChat(object sender, ChatArgs e) { IRCChannel channel = GetChannelByName(m_defaultChannel); if (channel != null) { IRCUser user = GetUserByName(e.Source.Name.Replace(' ', '_')); if (user != null && user.TCPClient == null) { SendToChannel(channel, user, IRCMessageType.Privmsg, e.Message); } } }
private double?ChatPrioritizer(InterestListEvent eventData, IScenePresence presence) { ChatArgs args = (ChatArgs)eventData.State; switch (args.Type) { case EntityChatType.Owner: case EntityChatType.Debug: return(0.0); case EntityChatType.Broadcast: return(1.0); default: return(InterestListEventHandler.DefaultPrioritizer(eventData, presence)); } }
private void Server_OnServerChatMessage(object sender, ChatArgs e) { TextBoxBase control = richTextBoxReceiveSay; // Lets assume that is the case switch (e.Type) { case ChatType.CHAT_TYPE_YELL: control = richTextBoxReceiveYell; break; case ChatType.CHAT_TYPE_SYSTEM: control = richTextBoxReceiveSystemMsg; break; } Invoke(MyDelegate, new object[] { control, $"{e.Name}: {e.Message}" }); }
private void ChatHandler(object sender, ChatArgs e) { // This scene callback allows us to handle chat that originates from any protocol or // module, not just LLUDP chat. A random UUID is generated for each chat message to // prevent new chat messages from overwriting old ones if (e.Channel == 0) { Vector3 scenePosition; if (e.Source != null) { scenePosition = e.Source.ScenePosition; } else { scenePosition = Vector3.Zero; } if (e.Type == EntityChatType.Owner || e.Type == EntityChatType.Debug) { IScenePresence owner; if (m_scene.TryGetPresence(e.Source.OwnerID, out owner)) { // NOTE: Audible distance is ignored for EntityChatType.[Owner/Debug] m_scene.CreateInterestListEventFor(owner, new InterestListEvent(UUID.Random(), VIEWER_CHAT, scenePosition, Vector3.Zero, e)); } else { m_log.Warn("Can't send direct chat to missing presence " + e.Source.OwnerID); } } else { m_scene.CreateInterestListEvent(new InterestListEvent(UUID.Random(), VIEWER_CHAT, scenePosition, new Vector3(e.AudibleDistance), e)); } } }
private void EntityChatHandler(object sender, ChatArgs e) { if (e.Source is IScenePresence) { int startParam = e.Message.IndexOf('('); int endParam = e.Message.IndexOf(')'); if (startParam > 2 && endParam > startParam) { // Try and parse this into a function call string name = e.Message.Substring(0, startParam); ApiMethod apiMethod; if (m_scene.TryGetApiMethod(name, out apiMethod)) { // Parse the parameters ++startParam; List<string> parameters = ParseParameters(e.Message.Substring(startParam, endParam - startParam)); // Parameters sanity check ParameterInfo[] parameterInfos = apiMethod.MethodInfo.GetParameters(); if (parameters != null && parameters.Count == parameterInfos.Length - 1) { // Convert the parameters into the required types object[] objParameters = ConvertParameters(parameterInfos, parameters); if (objParameters != null) { object ret = m_scriptInstance.CallMethod(name, objParameters); } } } } } }
private void ChatHandler(object sender, ChatArgs e) { // This scene callback allows us to handle chat that originates from any protocol or // module, not just LLUDP chat. A random UUID is generated for each chat message to // prevent new chat messages from overwriting old ones if (e.Channel == 0) { Vector3 scenePosition; if (e.Source != null) scenePosition = e.Source.ScenePosition; else scenePosition = Vector3.Zero; if (e.Type == EntityChatType.Owner || e.Type == EntityChatType.Debug) { IScenePresence owner; if (m_scene.TryGetPresence(e.Source.OwnerID, out owner)) // NOTE: Audible distance is ignored for EntityChatType.[Owner/Debug] m_scene.CreateInterestListEventFor(owner, new InterestListEvent(UUID.Random(), VIEWER_CHAT, scenePosition, Vector3.Zero, e)); else m_log.Warn("Can't send direct chat to missing presence " + e.Source.OwnerID); } else { m_scene.CreateInterestListEvent(new InterestListEvent(UUID.Random(), VIEWER_CHAT, scenePosition, new Vector3(e.AudibleDistance), e)); } } }
public void ReceiveAddToChatNotification(object sender, ChatArgs chatArgs) { Console.WriteLine(this.Name + "- recieved that " + chatArgs.ChatMember.Name + " was added to chat"); }
public void ReceiveRemoveFromChatNotification(object sender, ChatArgs chatArgs) { Console.WriteLine(this.Name + "- recieved that " + chatArgs.ChatMember.Name + " was removed from chat"); }
//Notifications public void ReceiveAddedMessageNotification(object sender, ChatArgs chatArgs) { Console.WriteLine(this.Name + "- recieved that " + chatArgs.ChatMember.Name + " wrote message - " + chatArgs.Message); }
public void ReceiveRemoveFromChatNotification(object sender, ChatArgs chatArgs) { }
public void ReceiveAddToChatNotification(object sender, ChatArgs chatArgs) { }
private void SendChatPackets(QueuedInterestListEvent[] eventDatas, IScenePresence presence) { if (!(presence is LLAgent) || presence.InterestList == null) { return; } LLAgent agent = (LLAgent)presence; // We can't combine chat blocks together, so send a packet for each chat event // that is pulled off the event queue for (int i = 0; i < eventDatas.Length; i++) { ChatArgs data = (ChatArgs)eventDatas[i].Event.State; ChatAudibleLevel audible; ChatType type; string sourceName; ChatSourceType sourceType; string message; ChatFromSimulatorPacket packet = new ChatFromSimulatorPacket(); if (data.Source == null) { // System message audible = ChatAudibleLevel.Fully; type = ChatType.Normal; sourceName = m_scene.Name; message = data.Message; sourceType = ChatSourceType.System; packet.ChatData.FromName = Utils.StringToBytes(m_scene.Name); packet.ChatData.OwnerID = UUID.Zero; packet.ChatData.Position = Vector3.Zero; packet.ChatData.SourceID = m_scene.ID; } else { // Message from an agent or object sourceName = data.Source.Name; switch (data.Type) { case EntityChatType.Debug: type = ChatType.Debug; audible = ChatAudibleLevel.Fully; break; case EntityChatType.Owner: type = ChatType.OwnerSay; audible = ChatAudibleLevel.Fully; break; case EntityChatType.Broadcast: type = ChatType.Normal; audible = ChatAudibleLevel.Fully; break; default: type = GetChatType(data.AudibleDistance); audible = GetAudibleLevel(data.Source.ScenePosition, presence.ScenePosition, data.AudibleDistance); break; } if (audible == ChatAudibleLevel.Fully) { message = data.Message; } else { message = String.Empty; } if (data.Source is IScenePresence) { sourceType = ChatSourceType.Agent; } else { sourceType = ChatSourceType.Object; } packet.ChatData.FromName = Utils.StringToBytes(data.Source.Name); packet.ChatData.OwnerID = data.Source.OwnerID; packet.ChatData.Position = data.Source.ScenePosition; packet.ChatData.SourceID = data.Source.ID; } packet.ChatData.Audible = (byte)audible; packet.ChatData.ChatType = (byte)type; packet.ChatData.Message = Utils.StringToBytes(message); packet.ChatData.SourceType = (byte)sourceType; m_udp.SendPacket(agent, packet, ThrottleCategory.Task, false); } }
void m_scene_OnEntityChat(object sender, ChatArgs e) { IRCChannel channel = GetChannelByName(m_defaultChannel); if (channel != null) { IRCUser user = GetUserByName(e.Source.Name.Replace(' ', '_')); if (user != null && user.TCPClient == null) SendToChannel(channel, user, IRCMessageType.Privmsg, e.Message); } }