Annotation of /trunk/DefaultAgent/MessageChatManage.cs
Parent Directory
|
Revision Log
Revision 94 - (view) (download)
| 1 : | albert | 38 | using System; |
| 2 : | using System.Collections.Generic; | ||
| 3 : | using System.Linq; | ||
| 4 : | using System.Text; | ||
| 5 : | using OpenMetaverse; | ||
| 6 : | |||
| 7 : | namespace Xenki.DefaultAgent | ||
| 8 : | { | ||
| 9 : | public delegate void OnChatDelegate(string msg); | ||
| 10 : | |||
| 11 : | albert | 40 | public class MessageChatManage |
| 12 : | albert | 38 | { |
| 13 : | albert | 40 | private static GridClient Client; |
| 14 : | albert | 38 | |
| 15 : | albert | 40 | public event OnChatDelegate OnChat; |
| 16 : | albert | 38 | |
| 17 : | albert | 40 | public MessageChatManage(GridClient client) |
| 18 : | { | ||
| 19 : | Client = client; | ||
| 20 : | Client.Self.OnChat += new AgentManager.ChatCallback(Self_OnChat); | ||
| 21 : | Client.Self.OnInstantMessage += new AgentManager.InstantMessageCallback(Self_OnInstantMessage); | ||
| 22 : | albert | 44 | |
| 23 : | albert | 40 | } |
| 24 : | albert | 38 | |
| 25 : | albert | 44 | public void SendChatMessage(string msg,int channel, ChatType type) |
| 26 : | { | ||
| 27 : | Client.Self.Chat(msg,channel,type); | ||
| 28 : | } | ||
| 29 : | |||
| 30 : | albert | 40 | void Self_OnInstantMessage(InstantMessage im, Simulator simulator) |
| 31 : | { | ||
| 32 : | albert | 44 | OnMessage(im.FromAgentName + ":" + im.Message); |
| 33 : | albert | 40 | } |
| 34 : | albert | 38 | |
| 35 : | |||
| 36 : | albert | 40 | private void OnMessage(string msg) |
| 37 : | { | ||
| 38 : | if (OnChat != null) | ||
| 39 : | OnChat(msg); | ||
| 40 : | } | ||
| 41 : | void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position) | ||
| 42 : | { | ||
| 43 : | albert | 44 | if (type == ChatType.StartTyping) |
| 44 : | OnMessage(fromName + " is typing..."); | ||
| 45 : | else if (type == ChatType.StopTyping) | ||
| 46 : | { } | ||
| 47 : | else if (type == ChatType.Shout) | ||
| 48 : | { | ||
| 49 : | OnMessage(fromName + " is shouting"); | ||
| 50 : | } | ||
| 51 : | else if (type == ChatType.Whisper) | ||
| 52 : | { | ||
| 53 : | OnMessage(fromName + " whispered"); | ||
| 54 : | } | ||
| 55 : | else | ||
| 56 : | { | ||
| 57 : | string msg = fromName + " :" + message; | ||
| 58 : | OnMessage(msg); | ||
| 59 : | } | ||
| 60 : | albert | 40 | } |
| 61 : | albert | 94 | |
| 62 : | |||
| 63 : | #region Communicate | ||
| 64 : | |||
| 65 : | public Dictionary<UUID, FriendInfo> GetMyFrinds() | ||
| 66 : | { | ||
| 67 : | Dictionary<UUID,FriendInfo> friends = new Dictionary<UUID,FriendInfo>(); | ||
| 68 : | Client.Friends.FriendList.ForEach(delegate(FriendInfo f) | ||
| 69 : | { | ||
| 70 : | if (!friends.ContainsKey(f.UUID)) | ||
| 71 : | friends.Add(f.UUID, f); | ||
| 72 : | }); | ||
| 73 : | |||
| 74 : | return friends; | ||
| 75 : | } | ||
| 76 : | |||
| 77 : | public void SendMessage2Friend(string message,UUID friendid) | ||
| 78 : | { | ||
| 79 : | Client.Self.InstantMessage(friendid, message); | ||
| 80 : | } | ||
| 81 : | |||
| 82 : | #endregion | ||
| 83 : | albert | 38 | } |
| 84 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

