public IntPtr LoadAudioStreamFromUrl(string url, string cacheDirectory) { lock (audioUrlStreamLoaderLockObject) { lock (audioDataCache) { if (audioDataCache.ContainsKey(url)) { return(audioDataCache[url].AudioStreamPointer); } } AudioDataCache dataCache = new AudioDataCache(); dataCache.CachePath = cacheDirectory + Path.GetFileName(url); dataCache.CacheStream = new FileStream(dataCache.CachePath + ".tmp", FileMode.Create, FileAccess.Write); dataCache.CallbackDelegate = new DownloadCallbackDelegate(AudioDownloadCallback); IntPtr urlPtr = Marshal.StringToHGlobalUni(url); lock (audioDataCache) { if (audioDataCache.ContainsKey(url) == false) { audioDataCache.Add(url, dataCache); } else { dataCache.CallbackDelegate = null; if (urlPtr != IntPtr.Zero) { Marshal.FreeHGlobal(urlPtr); urlPtr = IntPtr.Zero; } } } dataCache.AudioStreamPointer = Bass.BASS_StreamCreateURL(url, 0, 0, dataCache.CallbackDelegate, urlPtr); if (dataCache.AudioStreamPointer == IntPtr.Zero) { // Uh oh! We couldn't play the sfx stream! lock (audioDataCache) { if (audioDataCache.ContainsKey(url)) { audioDataCache.RemoveAtKey(url); } if (urlPtr != IntPtr.Zero) { Marshal.FreeHGlobal(urlPtr); urlPtr = IntPtr.Zero; } } dataCache.CacheStream.Close(); File.Delete(dataCache.CachePath + ".tmp"); dataCache.CachePath = null; } return(dataCache.AudioStreamPointer); } }
public void Remove(string connectionID) { lock (lockObject) { players.RemoveAtKey(connectionID); } }
public void RemoveTimer(string timerID) { if (TimerExists(timerID)) { timers[timerID].Stop(); timers[timerID].Dispose(); timers.RemoveAtKey(timerID); } }
public static void HandleMemberLogout(string partyID, string leavingChar) { Party party = FindParty(partyID); int onlineClients = 0; if (party != null) { foreach (Client client in party.GetOnlineMemberClients()) { if (client.Player.CharID != leavingChar) { onlineClients++; } } if (onlineClients <= 0) { parties.RemoveAtKey(partyID); } } }
public void Remove(string tournamentID) { tournaments.RemoveAtKey(tournamentID); }