public void RequestGodlikePowers( UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) { ScenePresence sp = m_scene.GetScenePresence(agentID); if (sp != null) { if (godLike == false) { sp.GrantGodlikePowers(agentID, sessionID, token, godLike); return; } // First check that this is the sim owner if (m_scene.Permissions.IsGod(agentID)) { // Next we check for spoofing..... UUID testSessionID = sp.ControllingClient.SessionId; if (sessionID == testSessionID) { if (sessionID == controllingClient.SessionId) { //m_log.Info("godlike: " + godLike.ToString()); sp.GrantGodlikePowers(agentID, testSessionID, token, godLike); } } } else { if (m_dialogModule != null) m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied"); } } }
/// <summary> /// Sends the details about what /// </summary> /// <param name="client"></param> /// <param name="agentID"></param> /// <param name="groupID"></param> /// <param name="transactionID"></param> /// <param name="sessionID"></param> /// <param name="currentInterval"></param> /// <param name="intervalDays"></param> private void client_OnGroupAccountDetailsRequest(IClientAPI client, UUID agentID, UUID groupID, UUID transactionID, UUID sessionID, int currentInterval, int intervalDays) { IGroupsModule groupsModule = client.Scene.RequestModuleInterface<IGroupsModule>(); if (groupsModule != null && groupsModule.GroupPermissionCheck(agentID, groupID, GroupPowers.Accountable)) { IMoneyModule moneyModule = client.Scene.RequestModuleInterface<IMoneyModule>(); if (moneyModule != null) { int amt = moneyModule.Balance(groupID); List<GroupAccountHistory> history = moneyModule.GetTransactions(groupID, agentID, currentInterval, intervalDays); history = (from h in history where h.Stipend select h).ToList(); //We don't want payments, we only want stipends which we sent to users GroupBalance balance = moneyModule.GetGroupBalance(groupID); client.SendGroupAccountingDetails(client, groupID, transactionID, sessionID, amt, currentInterval, intervalDays, Util.BuildYMDDateString( balance.StartingDate.AddDays(-currentInterval*intervalDays)), history.ToArray()); } else client.SendGroupAccountingDetails(client, groupID, transactionID, sessionID, 0, currentInterval, intervalDays, "Never", new GroupAccountHistory[0]); } }
public void OnConnectionClose(IClientAPI client) { if (client == null) return; if (client.SceneAgent == null) return; if (client.SceneAgent.IsChildAgent) return; //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", userId, client.Scene.RegionInfo.RegionName); string userId; /* without scene we cannot logout correctly at all since we do not know how to send the loggedout message then */ if (client.Scene is Scene) { Scene s = (Scene)client.Scene; userId = s.UserManagementModule.GetUserUUI(client.AgentId); if(s.UserManagementModule.GetUserUUI(client.AgentId, out userId)) { m_GridUserService.LoggedOut( userId, client.SessionId, client.Scene.RegionInfo.RegionID, client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat); } } }
protected void ObjectSaleInfo( IClientAPI client, UUID agentID, UUID sessionID, uint localID, byte saleType, int salePrice) { SceneObjectPart part = m_scene.GetSceneObjectPart(localID); if (part == null) return; if (part.ParentGroup.IsDeleted) return; if (part.OwnerID != part.GroupID && part.OwnerID != client.AgentId && (!m_scene.Permissions.IsGod(client.AgentId))) return; if (part.OwnerID == part.GroupID) // Group owned { // Does the user have the power to put the object on sale? if (!m_scene.Permissions.CanSellGroupObject(client.AgentId, part.GroupID, m_scene)) { client.SendAgentAlertMessage("You don't have permission to set group-owned objects on sale", false); return; } } part = part.ParentGroup.RootPart; part.ObjectSaleType = saleType; part.SalePrice = salePrice; part.ParentGroup.HasGroupChanged = true; part.SendPropertiesToClient(client); }
void SignificantClientMovement(IClientAPI remote_client) { if (remote_client.AgentId != m_presence.UUID) return; if(m_presence.DrawDistance == 0) return; //This checks to see if we need to send more updates to the avatar since they last moved EntityBase[] Entities = m_presence.Scene.Entities.GetEntities(); foreach (EntityBase entity in Entities) { if (entity is SceneObjectGroup) //Only objects { //Check to see if they are in range if (Util.DistanceLessThan(m_presence.CameraPosition, entity.AbsolutePosition, m_presence.DrawDistance)) { //Check if we already have sent them an update if (!m_objectsInView.Contains(entity.UUID)) { if (m_pendingObjects != null) { //Update the list m_objectsInView.Add(entity.UUID); //Enqueue them for an update m_pendingObjects.Enqueue((SceneObjectGroup)entity); } } } } } Entities = null; }
/// <summary> /// Process transfer data received from the client. /// </summary> /// <param name="xferID"></param> /// <param name="packetID"></param> /// <param name="data"></param> /// <returns>True if the transfer is complete, false otherwise or if the xferID was not valid</returns> public bool HandleXferPacket(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { if (XferID == xferID) { if (m_asset.Data.Length > 1) { byte[] destinationArray = new byte[m_asset.Data.Length + data.Length]; Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length); Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length); m_asset.Data = destinationArray; } else { byte[] buffer2 = new byte[data.Length - 4]; Array.Copy(data, 4, buffer2, 0, data.Length - 4); m_asset.Data = buffer2; } remoteClient.SendConfirmXfer(xferID, packetID); if ((packetID & 0x80000000) != 0) { SendCompleteMessage(remoteClient); return true; } } return false; }
public virtual void DeactivateGesture(IClientAPI client, List<UUID> gestureIds) { IInventoryProviderSelector selector = ProviderRegistry.Instance.Get<IInventoryProviderSelector>(); ICheckedInventoryStorage provider = selector.GetCheckedProvider(client.AgentId); provider.DeactivateGestures(client.AgentId, gestureIds); }
/// <summary> /// Process transfer data received from the client. /// </summary> /// <param name = "xferID"></param> /// <param name = "packetID"></param> /// <param name = "data"></param> public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { if (mXferID == xferID) { // if (m_asset.Data.Length > 1)//comment out for raw terrain bug fix --VS lock (_lock) // added if (m_asset.Data.Length > 1) { byte[] destinationArray = new byte[m_asset.Data.Length + data.Length]; Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length); Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length); m_asset.Data = destinationArray; } else { byte[] buffer2 = new byte[data.Length - 4]; Array.Copy(data, 4, buffer2, 0, data.Length - 4); m_asset.Data = buffer2; } remoteClient.SendConfirmXfer(xferID, packetID); if ((packetID & 0x80000000) != 0) { SendCompleteMessage(remoteClient); } } }
/// <summary> /// Check to see if the client has baked textures that belong to banned clients /// </summary> /// <param name="client"></param> /// <param name="textureEntry"></param> public void CheckForBannedViewer(IClientAPI client, Primitive.TextureEntry textureEntry) { try { //Read the website once! if (m_map == null) m_map = (OSDMap)OSDParser.Deserialize(Utilities.ReadExternalWebsite("http://auroraserver.ath.cx:8080/client_tags.xml")); //This is the givaway texture! for (int i = 0; i < textureEntry.FaceTextures.Length; i++) { if (textureEntry.FaceTextures[i] != null) { if (m_map.ContainsKey(textureEntry.FaceTextures[i].TextureID.ToString())) { OSDMap viewerMap = (OSDMap)m_map[textureEntry.FaceTextures[i].TextureID.ToString()]; //Check the names if (BannedViewers.Contains(viewerMap["name"].ToString())) { client.Kick("You cannot use " + viewerMap["name"] + " in this sim."); ((Scene)client.Scene).IncomingCloseAgent(client.AgentId); } else if (m_banEvilViewersByDefault && viewerMap.ContainsKey("evil") && (viewerMap["evil"].AsBoolean() == true)) { client.Kick("You cannot use " + viewerMap["name"] + " in this sim."); ((Scene)client.Scene).IncomingCloseAgent(client.AgentId); } } } } } catch { } }
/// <summary> /// Process transfer data received from the client. /// </summary> /// <param name="xferID"></param> /// <param name="packetID"></param> /// <param name="data"></param> public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { if (mXferID != xferID) return; lock (this) { if (m_asset.Data.Length > 1) { byte[] destinationArray = new byte[m_asset.Data.Length + data.Length]; Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length); Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length); m_asset.Data = destinationArray; } else { byte[] buffer2 = new byte[data.Length - 4]; Array.Copy(data, 4, buffer2, 0, data.Length - 4); m_asset.Data = buffer2; } remoteClient.SendConfirmXfer(xferID, packetID); if ((packetID & 0x80000000) != 0) { SendCompleteMessage(remoteClient); } } }
public void RequestGodlikePowers ( UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) { IScenePresence sp = m_scene.GetScenePresence (agentID); if (sp != null) { if (godLike == false) { //Unconditionally remove god levels sp.GodLevel = Constants.USER_NORMAL; sp.ControllingClient.SendAdminResponse (token, (uint)sp.GodLevel); return; } // First check that this is the sim owner if (m_scene.Permissions.IsAdministrator (sp.UUID)) { sp.GodLevel = sp.UserLevel; if (sp.GodLevel == Constants.USER_NORMAL) sp.GodLevel = Constants.USER_GOD_MAINTENANCE; MainConsole.Instance.InfoFormat ("[GODS]: God level set for {0}, level {1}", sp.Name, sp.GodLevel); sp.ControllingClient.SendAdminResponse (token, (uint)sp.GodLevel); } else { if (m_dialogModule != null) m_dialogModule.SendAlertToUser (agentID, "Request for god powers denied. This request has been logged."); MainConsole.Instance.Info ("[GODS]: God powers requested by " + sp.Name + ", user is not allowed to have god powers"); } } }
public void HandleXfer(IClientAPI client, ulong xferID, uint packetID, byte[] data) { AssetXferUploader foundUploader = null; lock (XferUploaders) { foreach (AssetXferUploader uploader in XferUploaders.Values) { // MainConsole.Instance.DebugFormat( // "[AGENT ASSETS TRANSACTIONS]: In HandleXfer, inspect xfer upload with xfer id {0}", // uploader.XferID); if (uploader.XferID == xferID) { foundUploader = uploader; break; } } } if (foundUploader != null) { // MainConsole.Instance.DebugFormat( // "[AGENT ASSETS TRANSACTIONS]: Found xfer uploader for xfer id {0}, packet id {1}, data length {2}", // xferID, packetID, data.Length); foundUploader.HandleXferPacket(xferID, packetID, data); } }
public void OnNewClient(IClientAPI client) { //Detect object data changes by hooking into the IClientAPI. //Very dirty, and breaks whenever someone changes the client API. client.OnAddPrim += delegate (UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, PrimitiveBaseShape shape, byte bypassRaycast, Vector3 RayStart, UUID RayTargetID, byte RayEndIsIntersection) { this.Stale = true; }; client.OnLinkObjects += delegate (IClientAPI remoteClient, uint parent, List<uint> children) { this.Stale = true; }; client.OnDelinkObjects += delegate(List<uint> primIds, IClientAPI clientApi) { this.Stale = true; }; client.OnGrabUpdate += delegate(UUID objectID, Vector3 offset, Vector3 grapPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) { this.Stale = true; }; client.OnObjectAttach += delegate(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent) { this.Stale = true; }; client.OnObjectDuplicate += delegate(uint localID, Vector3 offset, uint dupeFlags, UUID AgentID, UUID GroupID) { this.Stale = true; }; client.OnObjectDuplicateOnRay += delegate(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID, UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart, bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) { this.Stale = true; }; client.OnObjectIncludeInSearch += delegate(IClientAPI remoteClient, bool IncludeInSearch, uint localID) { this.Stale = true; }; client.OnObjectPermissions += delegate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) { this.Stale = true; }; client.OnRezObject += delegate(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID) { this.Stale = true; }; }
private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) { uint sun = 0; if (!m_scene.RegionInfo.EstateSettings.UseGlobalTime) sun=(uint)(m_scene.RegionInfo.EstateSettings.SunPosition*1024.0) + 0x1800; UUID estateOwner; if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) estateOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; else estateOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID; if (m_scene.Permissions.IsGod(remote_client.AgentId)) estateOwner = remote_client.AgentId; remote_client.SendDetailedEstateData(invoice, m_scene.RegionInfo.EstateSettings.EstateName, m_scene.RegionInfo.EstateSettings.EstateID, m_scene.RegionInfo.EstateSettings.ParentEstateID, GetEstateFlags(), sun, m_scene.RegionInfo.RegionSettings.Covenant, m_scene.RegionInfo.EstateSettings.AbuseEmail, estateOwner); remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID); remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID); }
public void Add(uint id, IClientAPI client) { lock (m_clients) { m_clients.Add(id, client); } }
public override ISceneAgent AddNewClient(IClientAPI client, PresenceType type) { client.OnObjectName += RecordObjectNameCall; // FIXME return null; }
/// <summary> /// Teleport an avatar to their home region /// </summary> /// <param name="agentId"></param> /// <param name="client"></param> public override void TeleportClientHome(UUID agentId, IClientAPI client) { m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName); CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId); if (uinfo != null) { UserProfileData UserProfile = uinfo.UserProfile; if (UserProfile != null) { RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); //if (regionInfo != null) //{ // UserProfile.HomeRegionID = regionInfo.RegionID; // //CommsManager.UserService.UpdateUserProfile(UserProfile); //} if (regionInfo == null) { // can't find the Home region: Tell viewer and abort client.SendTeleportFailed("Your home-region could not be found."); return; } RequestTeleportLocation( client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome)); } } else client.SendTeleportFailed("Sorry! I lost your home-region information."); }
/// <summary> /// Delete the given object from the scene /// </summary> public void DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient, bool permissionToDelete) { if (Enabled) lock (m_inventoryTicker) m_inventoryTicker.Stop(); lock (m_inventoryDeletes) { DeleteToInventoryHolder dtis = new DeleteToInventoryHolder(); dtis.action = action; dtis.folderID = folderID; dtis.objectGroup = objectGroup; dtis.remoteClient = remoteClient; dtis.permissionToDelete = permissionToDelete; m_inventoryDeletes.Enqueue(dtis); } if (Enabled) lock (m_inventoryTicker) m_inventoryTicker.Start(); // Visually remove it, even if it isnt really gone yet. This means that if we crash before the object // has gone to inventory, it will reappear in the region again on restart instead of being lost. // This is not ideal since the object will still be available for manipulation when it should be, but it's // better than losing the object for now. if (permissionToDelete) objectGroup.DeleteGroup(false); }
public void OnConnectionClose(IClientAPI client) { client.OnConnectionClosed -= OnConnectionClose; if (client.IsLoggingOut) { object sp = null; Vector3 position = new Vector3(128, 128, 0); Vector3 lookat = new Vector3(0, 1, 0); if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) { if (sp is ScenePresence) { if (((ScenePresence)sp).IsChildAgent) return; position = ((ScenePresence)sp).AbsolutePosition; lookat = ((ScenePresence)sp).Lookat; } } m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); m_GridUserService.LoggedOut(client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, position, lookat); } }
private double GetPriorityByDistance(IClientAPI client, ISceneEntity entity) { ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence != null) { // If this is an update for our own avatar give it the highest priority if (presence == entity) return 0.0; // Use the camera position for local agents and avatar position for remote agents Vector3 presencePos = (presence.IsChildAgent) ? presence.AbsolutePosition : presence.CameraPosition; // Use group position for child prims Vector3 entityPos; if (entity is SceneObjectPart) entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; else entityPos = entity.AbsolutePosition; return Vector3.DistanceSquared(presencePos, entityPos); } return double.NaN; }
public void ClientConnect(IClientAPI client) { m_virtScene.UnSubscribeToClientPrimEvents(client); m_virtScene.UnSubscribeToClientPrimRezEvents(client); m_virtScene.UnSubscribeToClientInventoryEvents(client); if(m_virtScene.AttachmentsModule != null) ((AttachmentsModule)m_virtScene.AttachmentsModule).UnsubscribeFromClientEvents(client); //m_virtScene.UnSubscribeToClientTeleportEvents(client); m_virtScene.UnSubscribeToClientScriptEvents(client); IGodsModule virtGodsModule = m_virtScene.RequestModuleInterface<IGodsModule>(); if (virtGodsModule != null) ((GodsModule)virtGodsModule).UnsubscribeFromClientEvents(client); m_virtScene.UnSubscribeToClientNetworkEvents(client); m_rootScene.SubscribeToClientPrimEvents(client); client.OnAddPrim += LocalAddNewPrim; client.OnRezObject += LocalRezObject; m_rootScene.SubscribeToClientInventoryEvents(client); if (m_rootScene.AttachmentsModule != null) ((AttachmentsModule)m_rootScene.AttachmentsModule).SubscribeToClientEvents(client); //m_rootScene.SubscribeToClientTeleportEvents(client); m_rootScene.SubscribeToClientScriptEvents(client); IGodsModule rootGodsModule = m_virtScene.RequestModuleInterface<IGodsModule>(); if (rootGodsModule != null) ((GodsModule)rootGodsModule).UnsubscribeFromClientEvents(client); m_rootScene.SubscribeToClientNetworkEvents(client); }
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent) { m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); // If we can't take it, we can't attach it! SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); if (part == null) return; if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) return; // Calls attach with a Zero position if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) { m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); // Save avatar attachment information ScenePresence presence; if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { m_log.Info( "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", AttachmentPoint: " + AttachmentPt); m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); } } }
protected void EventManager_OnNewClient(IClientAPI client) { client.OnObjectRequest += RequestPrim; client.OnObjectSelect += SelectPrim; client.OnObjectDeselect += DeselectPrim; client.OnViewerEffect += ProcessViewerEffect; }
/// /// CapsUpdateInventoryItemAsset /// public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) { UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); return newAssetID; }
public void UnsubscribeFromClientEvents(IClientAPI client) { client.OnRezSingleAttachmentFromInv -= RezSingleAttachmentFromInventory; client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; client.OnObjectAttach -= AttachObject; client.OnObjectDetach -= DetachObject; client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory; }
public void OnConnectionClose(IClientAPI client) { if (!client.SceneAgent.IsChildAgent) { // m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); m_PresenceService.LogoutAgent(client.SessionId); } }
public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) { m_asset = new AssetBase(UUID.Zero, pClientFilename, type, pRemoteClient.AgentId.ToString()); m_asset.Data = new byte[0]; m_asset.Description = "empty"; m_asset.Local = true; m_asset.Temporary = true; }
public LLFileTransfer(IClientAPI clientAPI) { m_uploadHandlers = new Dictionary<ulong, XferUploadHandler>(); m_clientAPI = clientAPI; m_clientAPI.OnXferReceive += XferReceive; m_clientAPI.OnAbortXfer += AbortXferUploadHandler; }
public void SubscribeToClientEvents(IClientAPI client) { client.OnRezSingleAttachmentFromInv += RezSingleAttachmentFromInventory; client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; client.OnObjectAttach += AttachObject; client.OnObjectDetach += DetachObject; client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory; }
private void OnClosingClient(IClientAPI client) { client.OnSoundTrigger -= TriggerSound; }
protected void ProcessNewClient(IClientAPI client) { client.OnInstantMessage += ProcessInstantMessage; }
public void OnNewClient(IClientAPI client) { client.OnViewerStartAuction += StartAuction; }
/// <summary> /// Registered for event /// </summary> /// <param name="client"></param> private void OnNewClient(IClientAPI client) { client.OnRequestMapBlocks += RequestMapBlocks; client.OnMapItemRequest += HandleMapItemRequest; }
public void NewClient(IClientAPI client) { client.OnAssetUploadRequest += HandleUDPUploadRequest; client.OnXferReceive += HandleXfer; }
public void NewClient(IClientAPI client) { client.OnRequestXfer += RequestXfer; client.OnConfirmXfer += AckPacket; }
private void OnNewClient(IClientAPI client) { // Inventory giving is conducted via instant message client.OnInstantMessage += OnInstantMessage; }
private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { // m_log.DebugFormat( // "[INVENTORY TRANSFER]: {0} IM type received from client {1}. From={2} ({3}), To={4}", // (InstantMessageDialog)im.dialog, client.Name, // im.fromAgentID, im.fromAgentName, im.toAgentID); Scene scene = FindClientScene(client.AgentId); if (scene == null) // Something seriously wrong here. { return; } if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) { //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0])); if (im.binaryBucket.Length < 17) // Invalid { return; } UUID receipientID = new UUID(im.toAgentID); ScenePresence user = scene.GetScenePresence(receipientID); UUID copyID; // First byte is the asset type AssetType assetType = (AssetType)im.binaryBucket[0]; if (AssetType.Folder == assetType) { UUID folderID = new UUID(im.binaryBucket, 1); m_log.DebugFormat( "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory", folderID, new UUID(im.toAgentID)); InventoryFolderBase folderCopy = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); if (folderCopy == null) { client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false); return; } // The outgoing binary bucket should contain only the byte which signals an asset folder is // being copied and the following bytes for the copied folder's UUID copyID = folderCopy.ID; byte[] copyIDBytes = copyID.GetBytes(); im.binaryBucket = new byte[1 + copyIDBytes.Length]; im.binaryBucket[0] = (byte)AssetType.Folder; Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); if (user != null) { user.ControllingClient.SendBulkUpdateInventory(folderCopy); } // HACK!! // Insert the ID of the copied folder into the IM so that we know which item to move to trash if it // is rejected. // XXX: This is probably a misuse of the session ID slot. im.imSessionID = copyID.Guid; } else { // First byte of the array is probably the item type // Next 16 bytes are the UUID UUID itemID = new UUID(im.binaryBucket, 1); m_log.DebugFormat("[INVENTORY TRANSFER]: (giving) Inserting item {0} " + "into agent {1}'s inventory", itemID, new UUID(im.toAgentID)); InventoryItemBase itemCopy = scene.GiveInventoryItem( new UUID(im.toAgentID), client.AgentId, itemID); if (itemCopy == null) { client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); return; } copyID = itemCopy.ID; Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); if (user != null) { user.ControllingClient.SendBulkUpdateInventory(itemCopy); } // HACK!! // Insert the ID of the copied item into the IM so that we know which item to move to trash if it // is rejected. // XXX: This is probably a misuse of the session ID slot. im.imSessionID = copyID.Guid; } // Send the IM to the recipient. The item is already // in their inventory, so it will not be lost if // they are offline. // if (user != null) { user.ControllingClient.SendInstantMessage(im); return; } else { if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im, delegate(bool success) { if (!success) { client.SendAlertMessage("User not online. Inventory has been saved"); } }); } } } else if (im.dialog == (byte)InstantMessageDialog.InventoryAccepted) { ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); if (user != null) // Local { user.ControllingClient.SendInstantMessage(im); } else { if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im, delegate(bool success) { // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011 // and is apparently supposed to fix bulk inventory updates after accepting items. But // instead it appears to cause two copies of an accepted folder for the receiving user in // at least some cases. Folder/item update is already done when the offer is made (see code above) // // Send BulkUpdateInventory // IInventoryService invService = scene.InventoryService; // UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip // // InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); // folder = invService.GetFolder(folder); // // ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); // // // If the user has left the scene by the time the message comes back then we can't send // // them the update. // if (fromUser != null) // fromUser.ControllingClient.SendBulkUpdateInventory(folder); }); } } } // XXX: This code was placed here to try and accomodate RLV which moves given folders named #RLV/~<name> // to the requested folder, which in this case is #RLV. However, it is the viewer that appears to be // response from renaming the #RLV/~example folder to ~example. For some reason this is not yet // happening, possibly because we are not sending the correct inventory update messages with the correct // transaction IDs else if (im.dialog == (byte)InstantMessageDialog.TaskInventoryAccepted) { UUID destinationFolderID = UUID.Zero; if (im.binaryBucket != null && im.binaryBucket.Length >= 16) { destinationFolderID = new UUID(im.binaryBucket, 0); } if (destinationFolderID != UUID.Zero) { InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId); if (destinationFolder == null) { m_log.WarnFormat( "[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist", client.Name, scene.Name, destinationFolderID); return; } IInventoryService invService = scene.InventoryService; UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); item = invService.GetItem(item); InventoryFolderBase folder = null; UUID?previousParentFolderID = null; if (item != null) // It's an item { previousParentFolderID = item.Folder; item.Folder = destinationFolderID; invService.DeleteItems(item.Owner, new List <UUID>() { item.ID }); scene.AddInventoryItem(client, item); } else { folder = new InventoryFolderBase(inventoryID, client.AgentId); folder = invService.GetFolder(folder); if (folder != null) // It's a folder { previousParentFolderID = folder.ParentID; folder.ParentID = destinationFolderID; invService.MoveFolder(folder); } } // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code). if (previousParentFolderID != null) { InventoryFolderBase previousParentFolder = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId); previousParentFolder = invService.GetFolder(previousParentFolder); scene.SendInventoryUpdate(client, previousParentFolder, true, true); scene.SendInventoryUpdate(client, destinationFolder, true, true); } } } else if ( im.dialog == (byte)InstantMessageDialog.InventoryDeclined || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined) { // Here, the recipient is local and we can assume that the // inventory is loaded. Courtesy of the above bulk update, // It will have been pushed to the client, too // IInventoryService invService = scene.InventoryService; InventoryFolderBase trashFolder = invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); item = invService.GetItem(item); InventoryFolderBase folder = null; UUID?previousParentFolderID = null; if (item != null && trashFolder != null) { previousParentFolderID = item.Folder; item.Folder = trashFolder.ID; // Diva comment: can't we just update this item??? List <UUID> uuids = new List <UUID>(); uuids.Add(item.ID); invService.DeleteItems(item.Owner, uuids); scene.AddInventoryItem(client, item); } else { folder = new InventoryFolderBase(inventoryID, client.AgentId); folder = invService.GetFolder(folder); if (folder != null & trashFolder != null) { previousParentFolderID = folder.ParentID; folder.ParentID = trashFolder.ID; invService.MoveFolder(folder); } } if ((null == item && null == folder) | null == trashFolder) { string reason = String.Empty; if (trashFolder == null) { reason += " Trash folder not found."; } if (item == null) { reason += " Item not found."; } if (folder == null) { reason += " Folder not found."; } client.SendAgentAlertMessage("Unable to delete " + "received inventory" + reason, false); } // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code). else if (previousParentFolderID != null) { InventoryFolderBase previousParentFolder = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId); previousParentFolder = invService.GetFolder(previousParentFolder); scene.SendInventoryUpdate(client, previousParentFolder, true, true); scene.SendInventoryUpdate(client, trashFolder, true, true); } if (im.dialog == (byte)InstantMessageDialog.InventoryDeclined) { ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); if (user != null) // Local { user.ControllingClient.SendInstantMessage(im); } else { if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im, delegate(bool success) { }); } } } } }
protected virtual void EventManager_OnNewClient(IClientAPI client) { client.OnConnectionClosed += HandleConnectionClosed; client.OnNameFromUUIDRequest += HandleUUIDNameRequest; client.OnAvatarPickerRequest += HandleAvatarPickerRequest; }
protected virtual void HandleConnectionClosed(IClientAPI client) { client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; client.OnAvatarPickerRequest -= HandleAvatarPickerRequest; client.OnConnectionClosed -= HandleConnectionClosed; }
private void OnNewClient(IClientAPI client) { client.OnOfferCallingCard += OnOfferCallingCard; client.OnAcceptCallingCard += OnAcceptCallingCard; client.OnDeclineCallingCard += OnDeclineCallingCard; }
private UUID CreateCallingCard(UUID userID, UUID creatorID, UUID folderID, bool isGod) { IUserAccountService userv = m_Scenes[0].UserAccountService; if (userv == null) { return(UUID.Zero); } UserAccount info = userv.GetUserAccount(UUID.Zero, creatorID); if (info == null) { return(UUID.Zero); } IInventoryService inv = m_Scenes[0].InventoryService; if (inv == null) { return(UUID.Zero); } if (folderID == UUID.Zero) { InventoryFolderBase folder = inv.GetFolderForType(userID, AssetType.CallingCard); if (folder == null) // Nowhere to put it { return(UUID.Zero); } folderID = folder.ID; } m_log.DebugFormat("[XCALLINGCARD]: Creating calling card for {0} in inventory of {1}", info.Name, userID); InventoryItemBase item = new InventoryItemBase(); item.AssetID = UUID.Zero; item.AssetType = (int)AssetType.CallingCard; item.BasePermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify); if (isGod) { item.BasePermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Move); } item.EveryOnePermissions = (uint)PermissionMask.None; item.CurrentPermissions = item.BasePermissions; item.NextPermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify); item.ID = UUID.Random(); item.CreatorId = creatorID.ToString(); item.Owner = userID; item.GroupID = UUID.Zero; item.GroupOwned = false; item.Folder = folderID; item.CreationDate = Util.UnixTimeSinceEpoch(); item.InvType = (int)InventoryType.CallingCard; item.Flags = 0; item.Name = info.Name; item.Description = ""; item.SalePrice = 10; item.SaleType = (byte)SaleType.Not; inv.AddItem(item); IClientAPI client = FindClientObject(userID); if (client != null) { client.SendBulkUpdateInventory(item); } return(item.ID); }
private void OnNewClient(IClientAPI client) { client.OnSoundTrigger += TriggerSound; }
public bool BuyObject(IClientAPI remoteClient, UUID categoryID, uint localID, byte saleType, int salePrice) { SceneObjectPart part = m_scene.GetSceneObjectPart(localID); if (part == null) { return(false); } SceneObjectGroup group = part.ParentGroup; switch (saleType) { case 1: // Sell as original (in-place sale) uint effectivePerms = group.GetEffectivePermissions(); if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) { if (m_dialogModule != null) { m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale"); } return(false); } group.SetOwnerId(remoteClient.AgentId); group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId); if (m_scene.Permissions.PropagatePermissions()) { foreach (SceneObjectPart child in group.Parts) { child.Inventory.ChangeInventoryOwner(remoteClient.AgentId); child.TriggerScriptChangedEvent(Changed.OWNER); child.ApplyNextOwnerPermissions(); } } part.ObjectSaleType = 0; part.SalePrice = 10; part.ClickAction = Convert.ToByte(0); group.HasGroupChanged = true; part.SendPropertiesToClient(remoteClient); part.TriggerScriptChangedEvent(Changed.OWNER); group.ResumeScripts(); part.ScheduleFullUpdate(); break; case 2: // Sell a copy Vector3 inventoryStoredPosition = new Vector3( Math.Min(group.AbsolutePosition.X, m_scene.RegionInfo.RegionSizeX - 6), Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6), group.AbsolutePosition.Z); Vector3 originalPosition = group.AbsolutePosition; group.AbsolutePosition = inventoryStoredPosition; string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); group.AbsolutePosition = originalPosition; uint perms = group.GetEffectivePermissions(); if ((perms & (uint)PermissionMask.Transfer) == 0) { if (m_dialogModule != null) { m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale"); } return(false); } AssetBase asset = m_scene.CreateAsset( group.GetPartName(localID), group.GetPartDescription(localID), (sbyte)AssetType.Object, Utils.StringToBytes(sceneObjectXml), group.OwnerID); m_scene.AssetService.Store(asset); InventoryItemBase item = new InventoryItemBase(); item.CreatorId = part.CreatorID.ToString(); item.CreatorData = part.CreatorData; item.ID = UUID.Random(); item.Owner = remoteClient.AgentId; item.AssetID = asset.FullID; item.Description = asset.Description; item.Name = asset.Name; item.AssetType = asset.Type; item.InvType = (int)InventoryType.Object; item.Folder = categoryID; PermissionsUtil.ApplyFoldedPermissions(perms, ref perms); item.BasePermissions = perms & part.NextOwnerMask; item.CurrentPermissions = perms & part.NextOwnerMask; item.NextPermissions = part.NextOwnerMask; item.EveryOnePermissions = part.EveryoneMask & part.NextOwnerMask; item.GroupPermissions = part.GroupMask & part.NextOwnerMask; item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; item.CreationDate = Util.UnixTimeSinceEpoch(); if (m_scene.AddInventoryItem(item)) { remoteClient.SendInventoryItemCreateUpdate(item, 0); } else { if (m_dialogModule != null) { m_dialogModule.SendAlertToUser(remoteClient, "Cannot buy now. Your inventory is unavailable"); } return(false); } break; case 3: // Sell contents List <UUID> invList = part.Inventory.GetInventoryList(); bool okToSell = true; foreach (UUID invID in invList) { TaskInventoryItem item1 = part.Inventory.GetInventoryItem(invID); if ((item1.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) { okToSell = false; break; } } if (!okToSell) { if (m_dialogModule != null) { m_dialogModule.SendAlertToUser( remoteClient, "This item's inventory doesn't appear to be for sale"); } return(false); } if (invList.Count > 0) { m_scene.MoveTaskInventoryItems(remoteClient.AgentId, part.Name, part, invList); } break; } return(true); }
private void OnClosingClient(IClientAPI client) { client.OnRequestXfer -= RequestXfer; client.OnConfirmXfer -= AckPacket; }
protected override void StoreFriendships(UUID agentID, UUID friendID) { Boolean agentIsLocal = true; Boolean friendIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); } // Are they both local users? if (agentIsLocal && friendIsLocal) { // local grid users m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); DeletePreviousHGRelations(agentID, friendID); base.StoreFriendships(agentID, friendID); return; } // ok, at least one of them is foreigner, let's get their data IClientAPI agentClient = LocateClientObject(agentID); IClientAPI friendClient = LocateClientObject(friendID); AgentCircuitData agentClientCircuit = null; AgentCircuitData friendClientCircuit = null; string agentUUI = string.Empty; string friendUUI = string.Empty; string agentFriendService = string.Empty; string friendFriendService = string.Empty; if (agentClient != null) { agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); RecacheFriends(agentClient); } if (friendClient != null) { friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); RecacheFriends(friendClient); } m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", agentUUI, friendUUI, agentFriendService, friendFriendService); // Generate a random 8-character hex number that will sign this friendship string secret = UUID.Random().ToString().Substring(0, 8); string theFriendUUID = friendUUI + ";" + secret; string agentUUID = agentUUI + ";" + secret; if (agentIsLocal) // agent is local, 'friend' is foreigner { // This may happen when the agent returned home, in which case the friend is not there // We need to look for its information in the friends list itself FriendInfo[] finfos = null; bool confirming = false; if (friendUUI == string.Empty) { finfos = GetFriendsFromCache(agentID); foreach (FriendInfo finfo in finfos) { if (finfo.TheirFlags == -1) { if (finfo.Friend.StartsWith(friendID.ToString())) { friendUUI = finfo.Friend; theFriendUUID = friendUUI; UUID utmp = UUID.Zero; string url = String.Empty; string first = String.Empty; string last = String.Empty; // If it's confirming the friendship, we already have the full UUI with the secret if (Util.ParseUniversalUserIdentifier(theFriendUUID, out utmp, out url, out first, out last, out secret)) { agentUUID = agentUUI + ";" + secret; m_uMan.AddUser(utmp, first, last, url); } confirming = true; break; } } } if (!confirming) { friendUUI = m_uMan.GetUserUUI(friendID); theFriendUUID = friendUUI + ";" + secret; } friendFriendService = m_uMan.GetUserServerURL(friendID, "FriendsServerURI"); // m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", // agentUUI, friendUUI, agentFriendService, friendFriendService); } // Delete any previous friendship relations DeletePreviousRelations(agentID, friendID); // store in the local friends service a reference to the foreign friend FriendsService.StoreFriend(agentID.ToString(), theFriendUUID, 1); // and also the converse FriendsService.StoreFriend(theFriendUUID, agentID.ToString(), 1); //if (!confirming) //{ // store in the foreign friends service a reference to the local agent HGFriendsServicesConnector friendsConn = null; if (friendClientCircuit != null) // the friend is here, validate session { friendsConn = new HGFriendsServicesConnector(friendFriendService, friendClientCircuit.SessionID, friendClientCircuit.ServiceSessionID); } else // the friend is not here, he initiated the request in his home world { friendsConn = new HGFriendsServicesConnector(friendFriendService); } friendsConn.NewFriendship(friendID, agentUUID); //} } else if (friendIsLocal) // 'friend' is local, agent is foreigner { // Delete any previous friendship relations DeletePreviousRelations(agentID, friendID); // store in the local friends service a reference to the foreign agent FriendsService.StoreFriend(friendID.ToString(), agentUUI + ";" + secret, 1); // and also the converse FriendsService.StoreFriend(agentUUI + ";" + secret, friendID.ToString(), 1); if (agentClientCircuit != null) { // store in the foreign friends service a reference to the local agent HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(agentFriendService, agentClientCircuit.SessionID, agentClientCircuit.ServiceSessionID); friendsConn.NewFriendship(agentID, friendUUI + ";" + secret); } } else // They're both foreigners! { HGFriendsServicesConnector friendsConn; if (agentClientCircuit != null) { friendsConn = new HGFriendsServicesConnector(agentFriendService, agentClientCircuit.SessionID, agentClientCircuit.ServiceSessionID); friendsConn.NewFriendship(agentID, friendUUI + ";" + secret); } if (friendClientCircuit != null) { friendsConn = new HGFriendsServicesConnector(friendFriendService, friendClientCircuit.SessionID, friendClientCircuit.ServiceSessionID); friendsConn.NewFriendship(friendID, agentUUI + ";" + secret); } } // my brain hurts now }
public void SubscribeToClientEvents(IClientAPI client) { client.OnObjectSaleInfo += ObjectSaleInfo; }
public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle) { lock (m_rootAgents) { if (!m_rootAgents.Contains(remoteClient.AgentId)) { return; } } uint xstart = 0; uint ystart = 0; Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); if (itemtype == 6) // we only sevice 6 right now (avatar green dots) { if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) { // Local Map Item Request int tc = Environment.TickCount; List <mapItemReply> mapitems = new List <mapItemReply>(); mapItemReply mapitem = new mapItemReply(); if (m_scene.GetRootAgentCount() <= 1) { mapitem = new mapItemReply(); mapitem.x = (uint)(xstart + 1); mapitem.y = (uint)(ystart + 1); mapitem.id = UUID.Zero; mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()); mapitem.Extra = 0; mapitem.Extra2 = 0; mapitems.Add(mapitem); } else { m_scene.ForEachScenePresence(delegate(ScenePresence sp) { // Don't send a green dot for yourself if (!sp.IsChildAgent && sp.UUID != remoteClient.AgentId) { mapitem = new mapItemReply(); mapitem.x = (uint)(xstart + sp.AbsolutePosition.X); mapitem.y = (uint)(ystart + sp.AbsolutePosition.Y); mapitem.id = UUID.Zero; mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()); mapitem.Extra = 1; mapitem.Extra2 = 0; mapitems.Add(mapitem); } }); } remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); } else { // Remote Map Item Request // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. // Note that we only start up a remote mapItem Request thread if there's users who could // be making requests if (!threadrunning) { m_log.Warn("[WORLD MAP]: Starting new remote request thread manually. This means that AvatarEnteringParcel never fired! This needs to be fixed! Don't Mantis this, as the developers can see it in this message"); StartThread(new object()); } RequestMapItems("", remoteClient.AgentId, flags, EstateID, godlike, itemtype, regionhandle); } } }
protected override void OnNewClient(IClientAPI client) { client.OnTeleportHomeRequest += TeleportHome; client.OnTeleportLandmarkRequest += RequestTeleportLandmark; client.OnConnectionClosed += new Action <IClientAPI>(OnConnectionClosed); }
private void OnClosingClient(IClientAPI client) { client.OnViewerStartAuction -= StartAuction; }
private void OnAcceptCallingCard(IClientAPI client, UUID transactionID, UUID folderID) { }
protected void OnInstantMessage(IClientAPI client, GridInstantMessage im) { m_log.InfoFormat("[WATER WARS]: GameManagerTopLevelInteraction.OnInstantMessage received"); if (im.dialog == (byte)InstantMessageDialog.InventoryAccepted && client.AgentId == m_playerId) { m_log.InfoFormat("[WATER WARS]: Now we get to do something cool! IMSessionId [{0}]", im.imSessionID); UUID itemId = new UUID(im.imSessionID); Scene scene = client.Scene as Scene; // This really need to be a 'has inventory item' method in Scene.Inventory.cs InventoryItemBase item = new InventoryItemBase(itemId, m_playerId); item = scene.InventoryService.GetItem(item); if (item == null) { m_log.Error("[WATER WARS]: Failed to find item " + itemId); return; } else if (item.Name != HUD_ITEM_NAME) { m_log.InfoFormat( "[WATER WARS]: Ignoring hud item {0} since it's not a {1}", item.Name, HUD_ITEM_NAME); return; } uint attachmentPoint = (uint)AttachmentPoint.HUDTop; ScenePresence sp = scene.GetScenePresence(client.AgentId); List <SceneObjectGroup> existingAttachments = sp.GetAttachments(attachmentPoint); if (existingAttachments.Count == 0) { IAttachmentsModule module = client.Scene.RequestModuleInterface <IAttachmentsModule>(); SceneObjectGroup sog = (SceneObjectGroup)module.RezSingleAttachmentFromInventory( sp, new UUID(im.imSessionID), (uint)AttachmentPoint.HUDTop); // A tempoary messy solution to an occasional race where the attached hud sometimes ends up positioned // on the avatar itself and does not show up as attached within inventory. Thread.Sleep(1000); Vector3 newPos = new Vector3(0, 0, -0.1f); m_log.InfoFormat("[WATER WARS]: Resetting HUD position to {0}", newPos); module.UpdateAttachmentPosition(sog, newPos); /* * sog.UpdateGroupPosition(newPos); * sog.HasGroupChanged = true; * sog.ScheduleGroupForTerseUpdate(); */ } else { m_log.InfoFormat( "[WATER WARS]: Not attaching given hud for {0} since something is already attached at {1}", client.Name, attachmentPoint); } client.OnInstantMessage -= OnInstantMessage; } }
public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type);
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; 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); }); }
void OnClosingClient(IClientAPI client) { client.OnInstantMessage -= OnInstantMessage; }
private void DoCallingCardOffer(IClientAPI dest, UUID from) { UUID itemID = CreateCallingCard(dest.AgentId, from, UUID.Zero, false); dest.SendOfferCallingCard(from, itemID); }
public void SendAlertToUser(IClientAPI client, string message, bool modal) { client.SendAgentAlertMessage(message, modal); }
public void OnNewClient(IClientAPI client) { client.OnConnectionClosed += OnConnectionClose; }
public void SendAlertToUser(IClientAPI client, string message) { SendAlertToUser(client, message, false); }
void OnInstantMessage(IClientAPI client, GridInstantMessage im) { //MainConsole.Instance.InfoFormat("[Inventory transfer]: OnInstantMessage {0}", im.dialog); IScene clientScene = FindClientScene(client.AgentId); if (clientScene == null) { // Something seriously wrong here. MainConsole.Instance.DebugFormat("[Inventory transfer]: Cannot find originating user scene"); return; } if (im.Dialog == (byte)InstantMessageDialog.InventoryOffered) { //MainConsole.Instance.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0])); if (im.BinaryBucket.Length < 17) // Invalid { MainConsole.Instance.DebugFormat("[Inventory transfer]: Invalid length {0} for asset type {1}", im.BinaryBucket.Length, ((AssetType)im.BinaryBucket [0])); return; } UUID recipientID = im.ToAgentID; IScenePresence recipientUser = null; IScene recipientUserScene = FindClientScene(recipientID); if (recipientUserScene != null) { recipientUser = recipientUserScene.GetScenePresence(recipientID); } UUID copyID; // give the item to the recipient, assuming they will accept it // First byte is the asset type AssetType assetType = (AssetType)im.BinaryBucket [0]; if (assetType == AssetType.Folder) { var folderID = new UUID(im.BinaryBucket, 1); if (im.SessionID == folderID) { // this must be an offline message being processed. just pass it through if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im); } return; } MainConsole.Instance.DebugFormat( "[Inventory transfer]: Inserting original folder {0} into agent {1}'s inventory", folderID, im.ToAgentID); clientScene.InventoryService.GiveInventoryFolderAsync( recipientID, client.AgentId, folderID, UUID.Zero, (folder) => { if (folder == null) { client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false); return; } // The outgoing binary bucket should contain only the byte which signals an asset folder is // being copied and the following bytes for the copied folder's UUID copyID = folder.ID; byte [] copyIDBytes = copyID.GetBytes(); im.BinaryBucket = new byte [1 + copyIDBytes.Length]; im.BinaryBucket [0] = (byte)AssetType.Folder; Array.Copy(copyIDBytes, 0, im.BinaryBucket, 1, copyIDBytes.Length); im.SessionID = copyID; if (moneyService != null) { moneyService.Transfer(im.ToAgentID, im.FromAgentID, 0, "Inworld inventory folder transfer", TransactionType.GiveInventory); } if (recipientUser != null) { // user is on this region... update them recipientUser.ControllingClient.SendBulkUpdateInventory(folder); recipientUser.ControllingClient.SendInstantMessage(im); } else if (m_TransferModule != null) { // user is not in this region or not online... let them know m_TransferModule.SendInstantMessage(im); } }); } else { // Inventory item // First byte of the array is probably the item type // Next 16 bytes are the UUID var itemID = new UUID(im.BinaryBucket, 1); if (im.SessionID == itemID) { // this must be an offline message being processed. just pass it through if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im); } return; } MainConsole.Instance.DebugFormat( "[Inventory transfer]: (giving) Inserting item {0} into agent {1}'s inventory", itemID, im.ToAgentID); clientScene.InventoryService.GiveInventoryItemAsync( im.ToAgentID, im.FromAgentID, itemID, UUID.Zero, false, (itemCopy) => { if (itemCopy == null) { MainConsole.Instance.DebugFormat( "[Inventory transfer]: (giving) Unable to find item {0} to give to agent {1}'s inventory", itemID, im.ToAgentID); client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); return; } copyID = itemCopy.ID; Array.Copy(copyID.GetBytes(), 0, im.BinaryBucket, 1, 16); im.SessionID = itemCopy.ID; if (moneyService != null) { moneyService.Transfer(im.ToAgentID, im.FromAgentID, 0, "Inworld inventory item transfer", TransactionType.GiveInventory); } if (recipientUser != null) { // user is on this region... recipientUser.ControllingClient.SendBulkUpdateInventory(itemCopy); recipientUser.ControllingClient.SendInstantMessage(im); } else if (m_TransferModule != null) { // user is not present on this region or offline... let them know m_TransferModule.SendInstantMessage(im); } }); } } else if (im.Dialog == (byte)InstantMessageDialog.InventoryAccepted) { IScenePresence user = clientScene.GetScenePresence(im.ToAgentID); MainConsole.Instance.DebugFormat("[Inventory transfer]: Acceptance message received"); if (user != null) // Local { user.ControllingClient.SendInstantMessage(im); } else { if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im); } } } else if (im.Dialog == (byte)InstantMessageDialog.InventoryDeclined) { // Here, the recipient is local and we can assume that the // inventory is loaded. Courtesy of the above bulk update, // It will have been pushed to the client, too // IInventoryService invService = clientScene.InventoryService; MainConsole.Instance.DebugFormat("[Inventory transfer]: Declined message received"); InventoryFolderBase trashFolder = invService.GetFolderForType(client.AgentId, InventoryType.Unknown, FolderType.Trash); UUID inventoryID = im.SessionID; // The inventory item/folder, back from it's trip InventoryItemBase item = invService.GetItem(client.AgentId, inventoryID); InventoryFolderBase folder = null; // cannot delete if we do not have somewhere to put it if (trashFolder != null) { // Deleting an item if (item != null) { item.Folder = trashFolder.ID; var uuids = new List <UUID> { item.ID }; invService.DeleteItems(item.Owner, uuids); // delete the item from the client's inventory ILLClientInventory inventory = client.Scene.RequestModuleInterface <ILLClientInventory> (); if (inventory != null) { inventory.AddInventoryItemAsync(client, item); // send an inventory update to the client } } else { // deleting a folder folder = new InventoryFolderBase(inventoryID, client.AgentId); folder = invService.GetFolder(folder); if (folder != null) { folder.ParentID = trashFolder.ID; invService.MoveFolder(folder); client.SendBulkUpdateInventory(folder); } } } if ((item == null && folder == null) | trashFolder == null) { string reason = string.Empty; if (trashFolder == null) { reason += " Trash folder not found."; } if (item == null) { reason += " Item not found."; } if (folder == null) { reason += " Folder not found."; } client.SendAgentAlertMessage("Unable to delete received inventory" + reason, false); } if (moneyService != null) { moneyService.Transfer(im.ToAgentID, im.FromAgentID, 0, "Inworld inventory transfer declined", TransactionType.GiveInventory); } IScenePresence user = clientScene.GetScenePresence(im.ToAgentID); if (user != null) // Local { user.ControllingClient.SendInstantMessage(im); } else { if (m_TransferModule != null) { m_TransferModule.SendInstantMessage(im); } } } }