Annotation of /trunk/IdealistViewer/Application/Protocol.cs
Parent Directory
|
Revision Log
Revision 13 - (view) (download)
| 1 : | teravus | 2 | using System; |
| 2 : | using System.Collections.Generic; | ||
| 3 : | using System.Text; | ||
| 4 : | using OpenMetaverse; | ||
| 5 : | using OpenMetaverse.Rendering; | ||
| 6 : | |||
| 7 : | namespace IdealistViewer | ||
| 8 : | { | ||
| 9 : | public class SLProtocol | ||
| 10 : | { | ||
| 11 : | public delegate void GridConnected(); | ||
| 12 : | public delegate void Chat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, | ||
| 13 : | string fromName, UUID id, UUID ownerid, Vector3 position); | ||
| 14 : | public delegate void LandPatch(Simulator sim, int x, int y, int width, float[] data); | ||
| 15 : | public delegate void NewAvatar(Simulator sim, Avatar avatar, ulong regionHandle, | ||
| 16 : | ushort timeDilation); | ||
| 17 : | public delegate void NewPrim(Simulator sim, Primitive prim, ulong regionHandle, | ||
| 18 : | ushort timeDilation); | ||
| 19 : | public delegate void Login(LoginStatus status, string message); | ||
| 20 : | public delegate void ObjectKilled(Simulator sim, uint objectID); | ||
| 21 : | public delegate void ObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation); | ||
| 22 : | public delegate void SimConnected(Simulator sim); | ||
| 23 : | teravus | 13 | public delegate void ImageReceived(AssetTexture tex); |
| 24 : | teravus | 2 | |
| 25 : | public event NewAvatar OnNewAvatar; | ||
| 26 : | public event Chat OnChat; | ||
| 27 : | public event GridConnected OnGridConnected; | ||
| 28 : | public event SimConnected OnSimConnected; | ||
| 29 : | public event LandPatch OnLandPatch; | ||
| 30 : | public event Login OnLogin; | ||
| 31 : | public event NewPrim OnNewPrim; | ||
| 32 : | public event ObjectKilled OnObjectKilled; | ||
| 33 : | public event ObjectUpdated OnObjectUpdated; | ||
| 34 : | |||
| 35 : | GridClient m_user; | ||
| 36 : | public SLProtocol() | ||
| 37 : | { | ||
| 38 : | m_user = new GridClient(); | ||
| 39 : | //m_user.Settings.STORE_LAND_PATCHES = true; | ||
| 40 : | m_user.Settings.MULTIPLE_SIMS = true; | ||
| 41 : | m_user.Settings.OBJECT_TRACKING = true; | ||
| 42 : | m_user.Settings.AVATAR_TRACKING = true; | ||
| 43 : | teravus | 13 | //m_user.Settings. |
| 44 : | teravus | 2 | //m_user.Settings.ALWAYS_DECODE_OBJECTS = true; |
| 45 : | //m_user.Settings.SEND_AGENT_THROTTLE = true; | ||
| 46 : | //m_user.Settings.SEND_PINGS = true; | ||
| 47 : | |||
| 48 : | m_user.Network.OnConnected += gridConnectedCallback; | ||
| 49 : | m_user.Network.OnSimConnected += simConnectedCallback; | ||
| 50 : | m_user.Terrain.OnLandPatch += landPatchCallback; | ||
| 51 : | m_user.Self.OnChat += chatCallback; | ||
| 52 : | m_user.Objects.OnNewAvatar += newAvatarCallback; | ||
| 53 : | m_user.Objects.OnNewPrim += newPrim; | ||
| 54 : | m_user.Objects.OnObjectKilled += objectKilledCallback; | ||
| 55 : | m_user.Network.OnLogin += loginCallback; | ||
| 56 : | m_user.Objects.OnObjectUpdated += objectUpdatedCallback; | ||
| 57 : | teravus | 13 | //m_user.Assets.OnImageReceived += imageReceivedCallback; |
| 58 : | //m_user.Assets.RequestImage( | ||
| 59 : | //m_user.Assets.Cache..RequestImage(UUID.Zero, ImageType.Normal); | ||
| 60 : | teravus | 2 | |
| 61 : | } | ||
| 62 : | teravus | 13 | //private void imageReceivedCallback(ImageDownload image, AssetTexture asset) |
| 63 : | //{ | ||
| 64 : | // image. | ||
| 65 : | //} | ||
| 66 : | teravus | 2 | private void objectKilledCallback(Simulator simulator, uint objectID) |
| 67 : | { | ||
| 68 : | if (OnObjectKilled != null) | ||
| 69 : | { | ||
| 70 : | OnObjectKilled(simulator, objectID); | ||
| 71 : | } | ||
| 72 : | } | ||
| 73 : | |||
| 74 : | public void BeginLogin(string loginURI, string username, string password) | ||
| 75 : | { | ||
| 76 : | LoginParams loginParams = getLoginParams(loginURI, username, password); | ||
| 77 : | |||
| 78 : | m_user.Network.BeginLogin(loginParams); | ||
| 79 : | } | ||
| 80 : | private void gridConnectedCallback(object sender) | ||
| 81 : | { | ||
| 82 : | |||
| 83 : | m_user.Appearance.SetPreviousAppearance(false); | ||
| 84 : | |||
| 85 : | |||
| 86 : | |||
| 87 : | if (OnGridConnected != null) | ||
| 88 : | { | ||
| 89 : | OnGridConnected(); | ||
| 90 : | } | ||
| 91 : | } | ||
| 92 : | private void simConnectedCallback(Simulator sender) | ||
| 93 : | { | ||
| 94 : | m_user.Throttle.Total = 500000; | ||
| 95 : | m_user.Throttle.Land = 80000; | ||
| 96 : | m_user.Throttle.Task = 200000; | ||
| 97 : | m_user.Throttle.Texture = 10000; | ||
| 98 : | m_user.Throttle.Wind = 10000; | ||
| 99 : | m_user.Throttle.Resend = 100000; | ||
| 100 : | m_user.Throttle.Asset = 100000; | ||
| 101 : | m_user.Throttle.Cloud = 10000; | ||
| 102 : | |||
| 103 : | |||
| 104 : | if (OnSimConnected != null) | ||
| 105 : | { | ||
| 106 : | OnSimConnected(sender); | ||
| 107 : | } | ||
| 108 : | } | ||
| 109 : | private void loginCallback(LoginStatus status, string message) | ||
| 110 : | { | ||
| 111 : | if (OnLogin != null) | ||
| 112 : | { | ||
| 113 : | OnLogin((LoginStatus)status, message); | ||
| 114 : | } | ||
| 115 : | } | ||
| 116 : | public void Logout() | ||
| 117 : | { | ||
| 118 : | if (m_user.Network.Connected) | ||
| 119 : | { | ||
| 120 : | m_user.Network.Logout(); | ||
| 121 : | } | ||
| 122 : | } | ||
| 123 : | public bool Connected | ||
| 124 : | { | ||
| 125 : | get { return m_user.Network.Connected; } | ||
| 126 : | } | ||
| 127 : | public void Whisper(string message) | ||
| 128 : | { | ||
| 129 : | m_user.Self.Chat(message, 0, ChatType.Whisper); | ||
| 130 : | } | ||
| 131 : | |||
| 132 : | public void Say(string message) | ||
| 133 : | { | ||
| 134 : | m_user.Self.Chat(message, 0, ChatType.Normal); | ||
| 135 : | } | ||
| 136 : | |||
| 137 : | public void Shout(string message) | ||
| 138 : | { | ||
| 139 : | m_user.Self.Chat(message, 0, ChatType.Shout); | ||
| 140 : | } | ||
| 141 : | |||
| 142 : | private LoginParams getLoginParams(string loginURI, string username, string password) | ||
| 143 : | { | ||
| 144 : | string firstname; | ||
| 145 : | string lastname; | ||
| 146 : | |||
| 147 : | Util.separateUsername(username, out firstname, out lastname); | ||
| 148 : | |||
| 149 : | LoginParams loginParams = m_user.Network.DefaultLoginParams( | ||
| 150 : | firstname, lastname, password, "IdealistViewer", "0.0.0.1");//Constants.Version); | ||
| 151 : | |||
| 152 : | loginParams.URI = Util.getSaneLoginURI(loginURI); | ||
| 153 : | |||
| 154 : | return loginParams; | ||
| 155 : | } | ||
| 156 : | |||
| 157 : | private void chatCallback(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, | ||
| 158 : | string fromName, UUID id, UUID ownerid, Vector3 position) | ||
| 159 : | { | ||
| 160 : | // This is weird -- we get start/stop typing chats from | ||
| 161 : | // other avatars, and we get messages back that we sent. | ||
| 162 : | // (Tested on OpenSim r3187) | ||
| 163 : | // So we explicitly check for those cases here. | ||
| 164 : | if (OnChat != null && (int)type < 4 && id != m_user.Self.AgentID) | ||
| 165 : | { | ||
| 166 : | OnChat(message, audible, type, sourcetype, | ||
| 167 : | fromName, id, ownerid, position); | ||
| 168 : | } | ||
| 169 : | } | ||
| 170 : | |||
| 171 : | |||
| 172 : | |||
| 173 : | private void newPrim(Simulator simulator, Primitive prim, ulong regionHandle, | ||
| 174 : | ushort timeDilation) | ||
| 175 : | { | ||
| 176 : | |||
| 177 : | if (OnNewPrim != null) | ||
| 178 : | { | ||
| 179 : | OnNewPrim(simulator,prim, regionHandle,timeDilation); | ||
| 180 : | } | ||
| 181 : | } | ||
| 182 : | |||
| 183 : | |||
| 184 : | private void landPatchCallback(Simulator simulator, int x, int y, int width, float[] data) | ||
| 185 : | { | ||
| 186 : | if (OnLandPatch != null) | ||
| 187 : | { | ||
| 188 : | OnLandPatch(simulator,x, y, width, data); | ||
| 189 : | } | ||
| 190 : | } | ||
| 191 : | private void newAvatarCallback(Simulator simulator, Avatar avatar, ulong regionHandle, | ||
| 192 : | ushort timeDilation) | ||
| 193 : | { | ||
| 194 : | if (OnNewAvatar != null) | ||
| 195 : | { | ||
| 196 : | //avatar.Velocity | ||
| 197 : | OnNewAvatar(simulator,avatar,regionHandle,timeDilation); | ||
| 198 : | } | ||
| 199 : | } | ||
| 200 : | private void objectUpdatedCallback(Simulator simulator, ObjectUpdate update, ulong regionHandle, | ||
| 201 : | ushort timeDilation) | ||
| 202 : | { | ||
| 203 : | if (OnObjectUpdated != null) | ||
| 204 : | { | ||
| 205 : | OnObjectUpdated(simulator, update, regionHandle, timeDilation); | ||
| 206 : | } | ||
| 207 : | } | ||
| 208 : | |||
| 209 : | |||
| 210 : | |||
| 211 : | } | ||
| 212 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

