protected override void OnNewSession(MsgSessionInfo msg) { PluginManager.EnableRealtimeReport(100); PluginManager.Log("==============================="); PluginManager.Log("==============================="); PluginManager.Log("OnNewSession: " + msg.Name + "@" + msg.ServerName); PluginManager.Log("==============================="); PluginManager.Log("==============================="); var server_config_ini = GatherServerConfigIni(); var trackId = msg.Track + "[" + msg.TrackConfig + "]"; MRBackend.NewSessionWithConfigAsync(msg.ServerName, trackId , msg.SessionType, msg.Laps, msg.WaitTime, msg.SessionDuration, msg.AmbientTemp, msg.RoadTemp, msg.ElapsedMS , TrustToken, _fingerprint, PluginVersion, -1, -1, -1, server_config_ini); var maxDrivers = TryParseMaxDrivers(server_config_ini); PluginManager.Log($"Max drivers: {maxDrivers}"); for (byte i = 0; i < maxDrivers; i++) { PluginManager.RequestCarInfo(i); } CurrentSessionStartTime = msg.CreationDate.AddMilliseconds(msg.ElapsedMS * -1); _distancesToReport.Clear(); if (trackId != CurrentTrackDefinition?.TrackName) { ReloadTrackDefinition(trackId); } }
protected override void OnSessionInfo(MsgSessionInfo msg) { if (msg.Type == ACSProtocol.MessageType.ACSP_NEW_SESSION || MRBackend.CurrentSessionGuid == Guid.Empty) { OnNewSession(msg); } }
protected override void OnSessionInfo(MsgSessionInfo msg) { //using (var a = new FileStream("Test.txt", FileMode.Append, FileAccess.Write)) //using (var b = new StreamWriter(a)) //{ // b.WriteLine($"{DateTime.Now.TimeOfDay}: OnSessionInfo Called {JsonConvert.SerializeObject(msg)}"); //} // PluginManager.EnableRealtimeReport((ushort)(PluginManager.RealtimeUpdateInterval * 5)); if (CurrentSession != null) { CurrentSession.AmbientTemp = msg.AmbientTemp; CurrentSession.ElapsedMs = msg.ElapsedMS; CurrentSession.RoadTemp = msg.RoadTemp; CurrentSession.ServerName = msg.ServerName; CurrentSession.SessionDuration = msg.SessionDuration; CurrentSession.SessionLaps = msg.Laps; CurrentSession.SessionName = msg.Name; CurrentSession.SessionTrack = msg.Track; CurrentSession.SessionTrackConfig = msg.TrackConfig; CurrentSession.SessionType = msg.SessionType; CurrentSession.SessionWaitTime = msg.WaitTime; CurrentSession.Version = msg.Version; CurrentSession.CurrentSessionIndex = msg.CurrentSessionIndex; CurrentSession.SessionCount = msg.SessionCount; CurrentSession.SessionIndex = msg.SessionIndex; CurrentSession.Weather = msg.Weather; CurrentSession = ApiWrapperNet4.Post <Session>("session/edit", CurrentSession); } else { CurrentSession = new Session { SessionId = Guid.NewGuid().ToString(), EventId = "", AmbientTemp = msg.AmbientTemp, ElapsedMs = msg.ElapsedMS, IsActive = true, RoadTemp = msg.RoadTemp, ServerName = msg.ServerName, SessionDuration = msg.SessionDuration, SessionLaps = msg.Laps, SessionName = msg.Name, SessionTrack = msg.Track, SessionTrackConfig = msg.TrackConfig, SessionType = msg.SessionType, SessionWaitTime = msg.WaitTime, Timestamp = DateTime.Now.TimeOfDay.Milliseconds, Version = msg.Version, CurrentSessionIndex = msg.CurrentSessionIndex, SessionCount = msg.SessionCount, SessionIndex = msg.SessionIndex, Weather = msg.Weather, SessionGame = "Assetto Corsa" }; CurrentSession = ApiWrapperNet4.Post <Session>("session/addsession", CurrentSession); } }
public void OnSessionInfo(MsgSessionInfo msg) { _inRaceSession = msg.SessionType == Game.SessionType.Race; _lapProgressComparer = new LapProgressComparer(_inRaceSession); foreach (var item in Leaderboard) { item.Reset(ResetBestLapTimeOnNewSession); } }
protected override void OnNewSession(MsgSessionInfo msg) { //using (var a = new FileStream("Test.txt", FileMode.Append, FileAccess.Write)) //using (var b = new StreamWriter(a)) //{ // b.WriteLine($"{DateTime.Now.TimeOfDay}: OnNewSession Called {msg.SessionType}"); //} // PluginManager.EnableRealtimeReport((ushort)(PluginManager.RealtimeUpdateInterval * 5)); CurrentSession = new Session { SessionId = Guid.NewGuid().ToString(), EventId = "", AmbientTemp = msg.AmbientTemp, ElapsedMs = msg.ElapsedMS, IsActive = true, RoadTemp = msg.RoadTemp, ServerName = msg.ServerName, SessionDuration = msg.SessionDuration, SessionLaps = msg.Laps, SessionName = msg.Name, SessionTrack = msg.Track, SessionTrackConfig = msg.TrackConfig, SessionType = msg.SessionType, SessionWaitTime = msg.WaitTime, Timestamp = DateTime.Now.TimeOfDay.Milliseconds, Version = msg.Version, CurrentSessionIndex = msg.CurrentSessionIndex, SessionCount = msg.SessionCount, SessionIndex = msg.SessionIndex, Weather = msg.Weather, SessionGame = "Assetto Corsa" }; CurrentSession = ApiWrapperNet4.Post <Session>("session/addsession", CurrentSession); Competitors.Where(comp => comp.IsConnected == true && comp.SessionId != CurrentSession.SessionId).ToList().ForEach(comp => { comp.SessionId = CurrentSession.SessionId; comp.CompetitorId = Guid.NewGuid().ToString(); ApiWrapperNet4.Post <Competitor>("competitor/addcompetitor", comp); }); }
protected override void OnNewSession(MsgSessionInfo msg) { if (this.PluginManager.PreviousSession != null && this.BroadcastResults > 0 && (this.PluginManager.PreviousSession.Laps.Count > 0 || this.PluginManager.PreviousSession.Incidents.Count > 0)) { this.PluginManager.BroadcastChatMessage(this.PluginManager.PreviousSession.SessionName + " Results:"); this.PluginManager.BroadcastChatMessage("Pos Name\tCar\tGap\tBestLap\tIncidents"); foreach (DriverInfo d in this.PluginManager.PreviousSession.Drivers.OrderBy(d => d.Position).Take(this.BroadcastResults)) { this.PluginManager.BroadcastChatMessage( string.Format( "{0} {1}\t{2}\t{3}\t{4}\t{5}", d.Position.ToString("00"), (d.DriverName == null || d.DriverName.Length <= 10) ? d.DriverName : d.DriverName.Substring(0, 10), (d.CarModel == null || d.CarModel.Length <= 10) ? d.CarModel : d.CarModel.Substring(0, 10), d.Gap, d.BestLapTxt, d.Incidents)); } } }
public virtual void OnNewSession(MsgSessionInfo msg) { }
public virtual void OnSessionInfo(MsgSessionInfo msg) { }
protected override void OnSessionInfo(MsgSessionInfo msg) { Console.WriteLine("SessionInfo: " + msg.ServerName + ", " + msg.Name + ", " + msg.ElapsedMS + ", index = " + msg.CurrentSessionIndex + ", WaitTime = " + msg.WaitTime); last = msg; }
protected override void OnSessionInfo(MsgSessionInfo msg) { base.OnNewSession(msg); this.form.BeginInvoke(new Action <MsgSessionInfo>(this.form.SetSessionInfo), msg); this.form.BeginInvoke(new Action(this.form.UpdateGui), null); }
public void SetSessionInfo(MsgSessionInfo msg) { if (msg != null) { this.currentSessionInfo = msg; sessionStart = DateTime.Now.AddMilliseconds(-msg.ElapsedMS); if (msg.SessionType == (byte)MsgSessionInfo.SessionTypeEnum.Race) { this.textBox_sessionInfo.Text = msg.Name + " " + msg.Laps + " laps, " + msg.Weather + ", ambient " + msg.AmbientTemp + "°, road " + msg.RoadTemp + "°"; } else { this.textBox_sessionInfo.Text = msg.Name + " " + msg.SessionDuration + " min, " + msg.Weather + ", ambient " + msg.AmbientTemp + "°, road " + msg.RoadTemp + "°"; } this.textBoxCurrentCycle.Text = msg.Track + " " + msg.TrackConfig; if (this.trackMap != null) { this.trackMap.Dispose(); this.trackMap = null; } string[] possibleFolders = new string[] { Path.Combine(this.trackCycler.ServerDirectory, "content", "tracks", msg.Track, msg.TrackConfig), Path.Combine(Path.GetDirectoryName(this.trackCycler.ServerDirectory.Substring(0, this.trackCycler.ServerDirectory.Length - 1)), "content", "tracks", msg.Track, msg.TrackConfig), }; foreach (string possibleFolder in possibleFolders) { if ((File.Exists(Path.Combine(possibleFolder, "map.png")) || File.Exists(Path.Combine(possibleFolder, "Data", "map.png"))) && File.Exists(Path.Combine(possibleFolder, "Data", "map.ini"))) { if (File.Exists(Path.Combine(possibleFolder, "map.png"))) { this.trackMap = Bitmap.FromFile(Path.Combine(possibleFolder, "map.png")); } else { this.trackMap = Bitmap.FromFile(Path.Combine(possibleFolder, "Data", "map.png")); } Bitmap copy = new Bitmap(this.trackMap.Width, this.trackMap.Height); using (Graphics graphics = Graphics.FromImage(copy)) { graphics.Clear(Color.White); graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; ColorMatrix colorMatrix = new ColorMatrix( new float[][] { new float[] { -1, 0, 0, 0, 0 }, new float[] { 0, -1, 0, 0, 0 }, new float[] { 0, 0, -1, 0, 0 }, new float[] { 0, 0, 0, 1, 0 }, new float[] { 1, 1, 1, 0, 1 } }); ImageAttributes attributes = new ImageAttributes(); attributes.SetColorMatrix(colorMatrix); graphics.DrawImage(this.trackMap, new Rectangle(0, 0, this.trackMap.Width, this.trackMap.Height), 0, 0, this.trackMap.Width, this.trackMap.Height, GraphicsUnit.Pixel, attributes); } this.trackMap.Dispose(); this.trackMap = copy; StreamReader reader = new StreamReader(Path.Combine(possibleFolder, "Data", "map.ini")); string line = reader.ReadLine(); while (line != null) { if (line.StartsWith("SCALE_FACTOR=")) { this.trackMapScale = double.Parse(line.Replace("SCALE_FACTOR=", ""), CultureInfo.InvariantCulture); } if (line.StartsWith("X_OFFSET=")) { this.trackMapOffsetX = double.Parse(line.Replace("X_OFFSET=", ""), CultureInfo.InvariantCulture); } if (line.StartsWith("Z_OFFSET=")) { this.trackMapOffsetY = double.Parse(line.Replace("Z_OFFSET=", ""), CultureInfo.InvariantCulture); } line = reader.ReadLine(); } reader.Dispose(); break; } } this.UpdatePositionGraph(); } }
protected internal virtual void OnNewSession(MsgSessionInfo msg) { }