public SnapshotSystem(NetMessenger messenger) { idAllocator = new IdAllocatorUInt16(); interfaces = new Dictionary <NetConnection, SnapshotConnectionInterface>(); snapshotsAwaitingDeltaSupport = new HashSet <Snapshot>(); channel = messenger.GetChannel((ushort)AOSChannelType.SnapshotSystem); channel.AddRemoteEvent("AllocateSnapshotId", R_AllocateSnapshotId); DashCMD.SetCVar("log_snapshots", false); }
// Should use argument -executeMethod SimulationManager.Init public static void Init() { //used for permissions purposes. when binary generates output logs, they do so under root, //and the editor does not have permissions to overwrite them. #if UNITY_EDITOR SimulationManager.logFileLocation = "output_log.txt"; #endif if (_hasFinishedInit) return; System.IO.File.WriteAllText(logFileLocation, "Starting Initialization:\n"); Application.logMessageReceived += HandleLog; List<string> args = new List<string>(System.Environment.GetCommandLineArgs()); Debug.Log ("args: " + args.ToString()); // default settings int screenWidth = Screen.width; int screenHeight = Screen.height; string preferredImageFormat = "png"; bool shouldCreateServer = true; bool shouldCreateTestClient = false; bool debugNetworkMessages = false; bool logSimpleTimeInfo = false; bool logDetailedTimeInfo = false; bool saveDebugImageFiles = false; string environmentScene = "Empty"; // Parse arguments { string output = "Args: "; foreach (string arg in args) { Debug.Log ("Arg: " + arg); output += "'" + arg + "' "; if (arg.StartsWith ("-port=")) { try { portNumber = arg.Substring ("-port=".IndexOf ("=") + 1); } catch { Debug.LogWarning ("No port number!"); } } else if (arg.StartsWith ("-address=")) { try { hostAddress = arg.Substring ("-address=".IndexOf ("=") + 1); } catch { Debug.LogWarning ("No host address!"); } } else if (arg.StartsWith ("-screenWidth=")) { try { screenWidth = int.Parse (arg.Substring ("-screenWidth=".IndexOf ("=") + 1)); } catch { Debug.LogWarning ("No screen width!"); } } else if (arg.StartsWith ("-screenHeight=")) { try { screenHeight = int.Parse (arg.Substring ("-screenHeight=".IndexOf ("=") + 1)); } catch { Debug.LogWarning ("No screen height!"); } } else if (arg.StartsWith ("-numTimeSteps=")) { try { numPhysicsFramesPerUpdate = int.Parse (arg.Substring ("-numTimeSteps=".IndexOf ("=") + 1)); } catch { Debug.LogWarning ("No num time steps!"); } } else if (arg.StartsWith ("-timeStep=")) { try { Time.fixedDeltaTime = int.Parse (arg.Substring ("-timeStep=".IndexOf ("=") + 1)); } catch { Debug.LogWarning ("No time step duration!"); } } else if (arg.StartsWith ("-profilerFrames=")) { try { profilerFrames = int.Parse (arg.Substring ("-profilerFrames=".IndexOf ("=") + 1)); } catch { Debug.LogWarning ("No profiler frames!"); } } else if (arg.StartsWith ("-preferredImageFormat=")) { try { preferredImageFormat = arg.Substring ("-preferredImageFormat=".IndexOf ("=") + 1); Debug.LogWarning ("DEPRECATED! Each client can specify its own format on join now which will overwrite this setting!"); } catch { Debug.LogWarning ("No targetFPS!"); } } else if (arg.StartsWith ("-shouldCreateServer")) { shouldCreateServer = true; } else if (arg.StartsWith ("-shouldCreateTestClient")) { shouldCreateTestClient = true; } else if (arg.StartsWith ("-debugNetworkMessages")) { debugNetworkMessages = true; } else if (arg.StartsWith ("-logSimpleTimingInfo")) { logSimpleTimeInfo = true; } else if (arg.StartsWith ("-logDetailedTimingInfo")) { logDetailedTimeInfo = true; } else if (arg.StartsWith ("-targetFPS")) { try { targetFrameRate = int.Parse (arg.Substring ("-targetFPS=".IndexOf ("=") + 1)); } catch { Debug.LogWarning ("No target FPS!"); } } else if (arg.StartsWith ("-saveDebugImageFiles=")) { saveDebugImageFiles = true; } } Debug.Log(output); } Screen.SetResolution(screenWidth, screenHeight, Screen.fullScreen); physicsTimeMultiplier = targetFrameRate * (Time.fixedDeltaTime * numPhysicsFramesPerUpdate * 1.05f); // Multiplier must be float between 0 and 100.0f if (physicsTimeMultiplier > 100) { targetFrameRate = Mathf.FloorToInt(targetFrameRate * 100f / physicsTimeMultiplier); physicsTimeMultiplier = targetFrameRate * (Time.fixedDeltaTime * numPhysicsFramesPerUpdate * 1.05f); } QualitySettings.vSyncCount = 0; Profiler.maxNumberOfSamplesPerFrame = profilerFrames; Application.targetFrameRate = targetFrameRate; // Debug.LogFormat("Setting target render FPS to {0} with speedup: {1} with phys timestep of {2} and {3} phys frames, maxDT: {4}", targetFrameRate, physicsTimeMultiplier, Time.fixedDeltaTime, numPhysicsFramesPerUpdate, Time.maximumDeltaTime); // Init NetMessenger myNetMessenger = GameObject.FindObjectOfType<NetMessenger>(); Debug.Log (portNumber); if (myNetMessenger != null) myNetMessenger.Init(hostAddress, portNumber, portNumber_info, shouldCreateTestClient,shouldCreateServer, debugNetworkMessages, logSimpleTimeInfo, logDetailedTimeInfo, preferredImageFormat, saveDebugImageFiles, environmentScene); else Debug.LogWarning("Couldn't find a NetMessenger to Initialize!"); _hasFinishedInit = true; }
public void InitNetData(NetMessenger myNewMessenger, NetMQ.Sockets.ResponseSocket myNewServer) { Debug.Log("Calling InitNetData"); _myMessenger = myNewMessenger; _myServer = myNewServer; _request.callbackFunc = (CameraStreamer.CaptureRequest req)=>{_myMessenger.SendFrameUpdate(req, this);}; ReadyFramesForRequest(); }