public void NotifyClients(NetScope scope, int frameId, int timeId, NetStream full) { lock (notifyQueueLock) { frameCapacity = clients.Count * NetScope.all.Count; for (int i = 0; i < clients.Count; i++) { if (clients[i].isReady) { full.AddRef(); notifyQueue.Enqueue(new NotifyClientTask { frameID = frameId, timeID = timeId, full = full, client = clients[i], scope = scope }); } } } if (!threaded) { HandleNotifyQueue(); } }
public NetStream BeginEvent(uint eventId) { if (scope == null) { scope = GetComponentInParent <NetScope>(); } NetStream netStream = scope.BeginEvent(this); netStream.WriteNetId(eventId); return(netStream); }
public bool DeliverEvent(NetStream stream) { if (scope == null) { scope = GetComponentInParent <NetScope>(); } uint num = stream.ReadNetId(); if (num - 1 < subscriptions.Count) { subscriptions[(int)(num - 1)](stream); return(true); } return(false); }
private IEnumerator EnterLobbyAsync(bool asServer, Action callback = null) { NetScope.ClearAllButPlayers(); object obj = stateLock; Monitor.Enter(obj); try { state = ((!asServer) ? AppSate.ClientLoadLobby : AppSate.ServerLoadLobby); SuspendDeltasForLoad(); Game.instance.HasSceneLoaded = false; string sceneName = null; if (Game.multiplayerLobbyLevel < 128) { sceneName = WorkshopRepository.GetLobbyFilename(Game.multiplayerLobbyLevel); goto IL_01fb; } bool loaded = false; WorkshopLevelMetadata workshopLevel = null; WorkshopRepository.instance.levelRepo.LoadLevel(Game.multiplayerLobbyLevel, delegate(WorkshopLevelMetadata l) { workshopLevel = l; loaded = true; }); while (!loaded) { yield return(null); } if (workshopLevel != null) { lobbyAssetbundle = FileTools.LoadBundle(workshopLevel.dataPath); string[] allScenePaths = lobbyAssetbundle.GetAllScenePaths(); sceneName = Path.GetFileNameWithoutExtension(allScenePaths[0]); StopPlaytimeForItem(previousLobbyID); StartPlaytimeForItem(workshopLevel.workshopId); previousLobbyID = workshopLevel.workshopId; goto IL_01fb; } if (NetGame.isServer) { goto IL_01fb; } SubtitleManager.instance.ClearProgress(); UnityEngine.Debug.Log("Level load failed."); instance.ServerFailedToLoad(); SignalManager.EndReset(); goto end_IL_0055; IL_01fb: if (string.IsNullOrEmpty(sceneName)) { sceneName = WorkshopRepository.GetLobbyFilename(0uL); Game.multiplayerLobbyLevel = 0uL; } AsyncOperation loader = SceneManager.LoadSceneAsync(sceneName); if (loader != null) { while (!loader.isDone || !Game.instance.HasSceneLoaded) { yield return(null); } } if (state != AppSate.ServerLoadLobby && state != AppSate.ClientLoadLobby) { UnityEngine.Debug.Log("Exiting wrong app state (" + state.ToString() + ")"); } state = ((!asServer) ? AppSate.ClientLobby : AppSate.ServerLobby); ResumeDeltasAfterLoad(); if (!RatingMenu.instance.ShowRatingMenu()) { MenuSystem.instance.ShowMainMenu <MultiplayerLobbyMenu>(); } Game.instance.state = GameState.Inactive; UpdateJoinable(); callback?.Invoke(); if (queueAfterLevelLoad != null) { Action action = queueAfterLevelLoad; queueAfterLevelLoad = null; if (NetGame.netlog) { UnityEngine.Debug.Log("Executing queue"); } action(); } if (lobbyAssetbundle != null) { lobbyAssetbundle.Unload(unloadAllLoadedObjects: false); lobbyAssetbundle = null; } Game.instance.FixAssetBundleImport(lobby: true); end_IL_0055 :; } finally { } }