public async Task <ActionResult <SessionTypes> > PostSessionTypes(SessionTypes sessionTypes)
        {
            _context.SessionTypes.Add(sessionTypes);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSessionTypes", new { id = sessionTypes.Id }, sessionTypes));
        }
        public async Task <IActionResult> PutSessionTypes(int id, SessionTypes sessionTypes)
        {
            if (id != sessionTypes.Id)
            {
                return(BadRequest());
            }

            _context.Entry(sessionTypes).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SessionTypesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
 public ClientChannel(string peerIP, int peerPort, string bindingIP, SessionTypes sessionType, ITraceProvider traceProvider, IChannelFormatter channelFormatter, int requestTimeout)
 {
     _peerAddress         = new Address(peerIP, peerPort);
     tcpChannel           = new TcpChannel(_peerAddress.IpAddress.ToString(), _peerAddress.Port, bindingIP, sessionType, traceProvider);
     tcpChannel.Formatter = channelFormatter;
     requestManager       = new RequestManager(tcpChannel, true, requestTimeout);
 }
Example #4
0
        public SessionInfo()
        {
            id           = 0;
            lapsTotal    = 0;
            lapsComplete = 0;
            leadChanges  = 0;
            cautions     = 0;
            cautionLaps  = 0;

            fastestlap    = 0;
            fastestdriver = new DriverInfo();
            fastestlapnum = 0;

            time = 0;
            sessiontimeremaining = 0;
            sessionlength        = 0;
            sessionstarttime     = -1;
            sessionstartpos      = 0;
            finishline           = Int32.MaxValue;

            type       = SessionTypes.none;
            state      = SessionStates.invalid;
            flag       = SessionFlags.invalid;
            startlight = SessionStartLights.off;

            standings      = new ObservableCollection <StandingsItem>();
            followedDriver = new StandingsItem();
        }
Example #5
0
 public void RegisterSessionListener(SessionTypes sessionType, ISessionListener listener)
 {
     lock (this)
     {
         _listeners[sessionType] = listener;
     }
 }
Example #6
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fSecsRunning = s.ReadDouble();
            fSession = (SessionTypes)s.ReadByte();
        }
Example #7
0
        public virtual IConfigurationServer GetConfigurationServer(TimeSpan timeout, SessionTypes sessionType, IChannelFormatter channelFormatter)
        {
            IConfigurationServer cs = null;

            try
            {
                cs = ConnectConfigurationService();
            }
            catch (SocketException exception)
            {
                if (exception.SocketErrorCode == SocketError.TimedOut)
                {
                    throw exception;
                }
                try
                {
                    Start(timeout);
                    cs = ConnectConfigurationService();
                }
                catch (Exception ex)
                {
                    throw  exception;
                }
            }

            return(cs);
        }
Example #8
0
 public void Connect(string serviceURI, SessionTypes sessionType)
 {
     //_bindIp = NetworkUtil.GetLocalIPAddress().ToString();
     _port = Int32.Parse(ConfigurationSettings.AppSettings["ConfigServerPort"]);
     SetURI(serviceURI);
     _firstConfiguratioServer = serviceURI;
     _sessionType             = sessionType;
 }
Example #9
0
 public Session(SessionTypes sessionType, IConnection connection, int localPort, int remotePort, IPAddress ip)
 {
     this.SessionType = sessionType;
     this.Connection  = connection;
     this.LocalPort   = localPort;
     this.RemotePort  = remotePort;
     this.IP          = ip;
 }
Example #10
0
 public void UnregisterSessionListener(SessionTypes sessionType, ISessionListener listener)
 {
     lock (this)
     {
         if (_listeners.ContainsKey(sessionType))
         {
             _listeners.Remove(sessionType);
         }
     }
 }
 public void UnregisterSessionListener(SessionTypes sessionType, ISessionListener listener)
 {
     lock (this)
     {
         if (_sessiionListioners[sessionType].Equals(listener))
         {
             _sessiionListioners.Remove(sessionType);
         }
     }
 }
 public void RegisterSessionListener(SessionTypes sessionType, ISessionListener listener)
 {
     if (sessionType.Equals(SessionTypes.Management))
     {
         lock (this)
         {
             _sessiionListioners[sessionType] = listener;
         }
     }
 }
        public static SessionState GetNewSession(SessionTypes sessionType)
        {
            var maxOccupany = ConfigManager.GetValue <UInt32>("MaxOccupany", 100).Value;
            var maxUserID   = ConfigManager.GetValue <UInt32>("MaxUserID", 9999).Value;
            var userID      = (UInt32)0;
            var loops       = 0;

            if (sessionStates.Count >= maxOccupany)
            {
                return(null); // Server Full!
            }

            do
            {
                userID = ServerState.lastIssuedUserID = ((ServerState.lastIssuedUserID + 1) % maxUserID);

                if (userID == 0)
                {
                    loops++;
                }
                if (loops > 1)
                {
                    return(null);           // Server Full!
                }
            } while (userID == 0 || sessionStates.ContainsKey(userID));

            INetworkDriver driver = null;

            switch (sessionType)
            {
            case SessionTypes.TcpSocket:
                driver = new PalaceSocketDriver();

                break;
            //case SessionTypes.ProxySocket:
            //    driver = new ProxySocketDriver();

            //    break;
            case SessionTypes.WebSocket:
                driver = new WebSocketDriver();

                break;
            }

            lock (sessionStates)
            {
                sessionStates.TryAdd(userID, new SessionState
                {
                    UserID = userID,
                    driver = driver,
                });
            }

            return(sessionStates[userID]);
        }
        public void OnConnectionEstablished(System.Net.Sockets.Socket connectedSocket)
        {
            try
            {
                if (connectedSocket != null && connectedSocket.Connected)
                {
                    byte[] dataBuffer = new byte[DATA_BUFFER_LENGTH];

                    NetworkUtil.ReadFromTcpSocket(connectedSocket, dataBuffer);

                    if (BitConverter.IsLittleEndian)
                    {
                        Array.Reverse(dataBuffer);
                    }

                    SessionTypes sessionType = (SessionTypes)BitConverter.ToInt32(dataBuffer, 0);

                    ISessionListener sessionListioner = null;

                    if (sessionType == SessionTypes.Management)
                    {
                        if (_sessiionListioners.ContainsKey(sessionType))
                        {
                            sessionListioner = _sessiionListioners[SessionTypes.Management];
                        }
                    }

                    if (sessionListioner != null)
                    {
                        IPEndPoint localEndPoint  = (IPEndPoint)connectedSocket.LocalEndPoint;
                        IPEndPoint remoteEndPoint = (IPEndPoint)connectedSocket.RemoteEndPoint;

                        IConnection connection;
                        connection = new TcpConnection(connectedSocket, sessionType);

                        sessionListioner.OnSessionEstablished(new Session(sessionType, connection, localEndPoint.Port, remoteEndPoint.Port, remoteEndPoint.Address));
                    }
                }
                else
                {
                    connectedSocket.Close();
                }
            }
            catch (Exception ex)
            {
                if (connectedSocket != null)
                {
                    connectedSocket.Close();
                }
                if (LoggerManager.Instance.ServerLogger != null && LoggerManager.Instance.ServerLogger.IsErrorEnabled)
                {
                    LoggerManager.Instance.ServerLogger.Error("ManagementShardServer.OnConnectionEstablished()", ex);
                }
            }
        }
Example #15
0
 public SessionEvent(SessionEventTypes type, Int64 replay, DriverInfo driver, String desc, SessionTypes session, Int32 lap)
 {
     this.type = type;
     this.timestamp = DateTime.Now;
     this.replaypos = replay;
     this.driver = driver;
     this.description = desc;
     this.session = session;
     this.lapnum = lap;
     this.rewind = 0;
 }
Example #16
0
 public SessionEvent(SessionEventTypes type, Int64 replay, DriverInfo driver, String desc, SessionTypes session, Int32 lap)
 {
     this.type        = type;
     this.timestamp   = DateTime.Now;
     this.replaypos   = replay;
     this.driver      = driver;
     this.description = desc;
     this.session     = session;
     this.lapnum      = lap;
     this.rewind      = 0;
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Session" /> class.
 /// </summary>
 /// <param name="sessionType">Type of the session.</param>
 /// <param name="talks">The talks.</param>
 /// <param name="date">The date.</param>
 public Session(SessionTypes sessionType, List <ITalk> talks, DateTime date)
 {
     //Use only date component and excluded time.
     date              = date.Date;
     SessionType       = sessionType;
     NextTalkStartTime = date;
     NextTalkStartTime = (sessionType == SessionTypes.Morning)
                      ? NextTalkStartTime.AddHours(9)   //Morning session starts @ 09:00 AM
                      : NextTalkStartTime.AddHours(13); //Afternoon session starts @ 01:00 PM
     BufferDuration = (sessionType == SessionTypes.Morning) ? 0 : Constants.DefaultBufferTime;
     Talks          = talks;
 }
Example #18
0
 public SessionInfo findSessionByType(SessionTypes type)
 {
     int index = sessions.FindIndex(s => s.Type.Equals(type));
     if (index >= 0)
     {
         return SessionList[index];
     }
     else
     {
         return new SessionInfo();
     }
 }
Example #19
0
 public Int32 findSessionIndexByType(SessionTypes type)
 {
     int index = sessions.FindIndex(s => s.Type.Equals(type));
     if (index >= 0)
     {
         return index;
     }
     else
     {
         return 0;
     }
 }
Example #20
0
        public DualChannel(string peerIP, int peerPort, string bindingIP, SessionTypes sessionType, ITraceProvider traceProvider, IChannelFormatter channelFormatter, int requestTimeout = 90)
        {
            tcpChannel           = new TcpChannel(peerIP, peerPort, bindingIP, sessionType, traceProvider);
            tcpChannel.Formatter = channelFormatter;
            requestManager       = new RequestManager(tcpChannel, false, requestTimeout);
            _peerAddress         = new Address(peerIP, peerPort);
            DualChannelListener _lisetner = new DualChannelListener(tcpChannel.UsesAsynchronousIO?null: new ClrThreadPool());

            _lisetner.RegisterRequestListener(this);
            _lisetner.RegisterResponseListener(requestManager);
            tcpChannel.RegisterEventListener(_lisetner);
        }
Example #21
0
        //Constructor for already connected socket to communicate over it
        public TcpConnection(Socket socket, SessionTypes sessionType /*, IPAddress bindIP*/)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("Socket is null");
            }

            this._socket    = socket;
            this._connected = _socket.Connected;
            _statusLatch.SetStatusBit((byte)Status.Connected, (byte)Status.Disconnected);
            this._sessionType = sessionType;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Session" /> class.
 /// </summary>
 /// <param name="sessionType">Type of the session.</param>
 /// <param name="talks">The talks.</param>
 /// <param name="date">The date.</param>
 public Session(SessionTypes sessionType, List<ITalk> talks, DateTime date)
 {
     //Use only date component and excluded time.
     date = date.Date;
     SessionType = sessionType;
     NextTalkStartTime = date;
     NextTalkStartTime = (sessionType == SessionTypes.Morning)
                      ? NextTalkStartTime.AddHours(9) //Morning session starts @ 09:00 AM
                      : NextTalkStartTime.AddHours(13); //Afternoon session starts @ 01:00 PM
     BufferDuration = (sessionType == SessionTypes.Morning) ? 0 : Constants.DefaultBufferTime;
     Talks = talks;
 }
Example #23
0
        public Int32 findSessionIndexByType(SessionTypes type)
        {
            int index = sessions.FindIndex(s => s.Type.Equals(type));

            if (index >= 0)
            {
                return(index);
            }
            else
            {
                return(0);
            }
        }
Example #24
0
 public TcpChannel(string serverIP, int port, string bindingIP, SessionTypes sessionType, ITraceProvider traceProvider)
 {
     if (string.IsNullOrEmpty(serverIP))
     {
         throw new ArgumentNullException("serverIP");
     }
     _serverIP      = serverIP;
     _port          = port;
     _bindIP        = bindingIP;
     _sessionType   = sessionType;
     _traceProvider = traceProvider;
     _sourceAddress = new Address(serverIP, port);
 }
Example #25
0
 private void OnSessionTypePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     try
     {
         List <String> SelSesiones      = SessionTypes.Where(s => s.IsSelectedItem).Select(z => z.SessionType).ToList();
         List <int>    IdsCinesAbiertos = CinemasPorSessionTypes.Where(s => SelSesiones.Contains(s.SessionType)).Select(z => z.CinemaId).Distinct().ToList();
         Cinemas.ToList().ForEach(c => c.IsSelectedItem = (IdsCinesAbiertos.Contains(c.Id)));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #26
0
        public SessionInfo findSessionByType(SessionTypes type)
        {
            int index = sessions.FindIndex(s => s.Type.Equals(type));

            if (index >= 0)
            {
                return(SessionList[index]);
            }
            else
            {
                return(new SessionInfo());
            }
        }
Example #27
0
 private bool CanExecuteFindPeliCommand()
 {
     try
     {
         bool ret = false;
         ret = (ret || (Peliculas != null && Peliculas.Any(p => p.IsSelectedItem)));
         ret = (ret || (Cinemas != null && Cinemas.Any(p => p.IsSelectedItem)));
         ret = (ret || (SessionTypes != null && SessionTypes.Any(p => p.IsSelectedItem)));
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #28
0
        public bool RemoveSessionType(string sessionType)
        {
            if (!SessionTypes.Contains(sessionType))
            {
                return(false);
            }

            //remove sessions with the given type
            foreach (var s in Sessions.Where(s => s.Type == sessionType).ToArray())
            {
                Sessions.Remove(s);
            }

            SessionTypes.Remove(sessionType);

            return(true);
        }
Example #29
0
        public bool AddSessionType(string sessionType)
        {
            if (SessionTypes.Contains(sessionType))
            {
                return(false);
            }

            SessionTypes.Add(sessionType);

            //generate sessions with the new type
            foreach (var name in SessionNames)
            {
                Sessions.Add(new Session(name, sessionType));
            }

            return(true);
        }
Example #30
0
        /// <summary>
        /// Create a fluent database session which will be tied to the provider specific implementation in the
        /// given <paramref name="connectionInformation"/>.  This is the entry point into the fluent ADO.Net api.
        /// At this point, no connection, command, or transaction is created.
        /// </summary>
        /// <param name="connectionInformation"></param>
        /// <returns></returns>
        /// <exception cref="FluentDatabaseSessionException"></exception>
        public static IManageTransactionOrCreateDbCommand CreateSession(FluentConnectionInformation connectionInformation)
        {
            var sessionType =
                SessionTypes.GetTypeWithCustomAttributeValue <FluentDataProviderAttribute, string>(
                    x => x.DataProviderName, connectionInformation.ProviderName) ??
                throw new FluentDatabaseSessionException("A valid connection string must be supplied");

            //create the fluent database session
            var currentSession = (DatabaseSession)Activator.CreateInstance(sessionType);

            currentSession.ConnectionInformation = connectionInformation;
            //set the db provider factory which is retrieved from the factory
            currentSession.DbProviderFactory = DbProviderFactories.GetFactory(connectionInformation.ProviderName);

            //give the provider specific implementation a chance to manipulate the connection
            //string such as handling an encrypted password.
            currentSession.ConnectionString = currentSession.GetConnectionString(connectionInformation);

            return(currentSession);
        }
 public ME7LoggerSession(string ME7LoggerDirectory, string filePath, SessionTypes sessionType = SessionTypes.LogFile, bool noWait = false)
 {
     this.Status             = Statuses.New;
     this.SessionType        = sessionType;
     this.ME7LoggerDirectory = ME7LoggerDirectory;
     this.FilePath           = filePath;
     if (this.SessionType == SessionTypes.LogFile)
     {
         this.Log = new ME7LoggerLog(this, this.FilePath, noWait);
     }
     else if (this.SessionType == SessionTypes.SessionOutput)
     {
         this.Log     = new ME7LoggerLog(this);
         this.options = new LoggerOptions("");
     }
     else
     {
         throw new ArgumentOutOfRangeException("sessionType");
     }
 }
Example #32
0
        public void Connect(string serviceURI, int port, SessionTypes sessionType, IChannelFormatter channelFormatter)
        {
            //_bindIp = NetworkUtil.GetLocalIPAddress().ToString(); ;
            _port             = port;
            _channelFormatter = channelFormatter;
            SetURI(serviceURI);
            _sessionType             = sessionType;
            _firstConfiguratioServer = serviceURI;

            try
            {
                Initialize(_firstConfiguratioServer, channelFormatter);
            }
            catch (Exception)
            {
                if (_secondConfiguratioServer != null)
                {
                    Initialize(_secondConfiguratioServer, channelFormatter);
                }
            }
        }
        public RemoteShardConnections(IChannelFactory factory, IChannelFormatter channelFormatter, ShardInfo shardInfo,
                                      TraceProvider traceProvider, SessionTypes sessionType)
        {
            _clientContexts    = new Dictionary <string, ClientContext>();
            _clientCredentials = new Dictionary <string, ClientCredential>();

            _factory          = factory;
            _channelFormatter = channelFormatter;
            _shardInfo        = shardInfo;
            _traceProvider    = traceProvider;
            if (shardInfo.Primary != null)
            {
                _primary =
                    new Server(
                        new Address(shardInfo.Primary.Address.IpAddress.ToString(), _shardInfo.Primary.Address.Port),
                        Status.Running); // If its primary it must be running
            }
            else
            {
                // TODO: Write exception to log
                //throw new Exception("At Query Distributor: No primary exists for " + shardInfo.Name);
            }
            _sessionType = sessionType;
        }
Example #34
0
 ISessionInfo ISessions.findSessionType(SessionTypes type)
 {
     return findSessionByType(type);
 }
 /// <summary>
 /// Returns an instance of session.
 /// </summary>
 /// <param name="sessionType">Type of the session.</param>
 /// <param name="date">The date of the sesssion.</param>
 /// <returns>Session</returns>
 public ISession GetNewSession(SessionTypes sessionType, DateTime date)
 {
     //Use only the date component and exclude time even if consumer send date with time.
     date = date.Date;
     return new Session(sessionType, new List<ITalk>(), date);
 }
Example #36
0
        public SessionInfo()
        {

            id = 0;
            lapsTotal = 0;
            lapsComplete = 0;
            leadChanges = 0;
            cautions = 0;
            cautionLaps = 0;

            fastestlap = 0;
            fastestdriver = new DriverInfo();
            fastestlapnum = 0;

            time = 0;
            sessiontimeremaining = 0;
            sessionlength = 0;
            sessionstarttime = -1;
            sessionstartpos = 0;
            finishline = Int32.MaxValue;

            type = SessionTypes.none;
            state = SessionStates.invalid;
            flag = SessionFlags.invalid;
            startlight = SessionStartLights.off;

            standings = new ObservableCollection<StandingsItem>();
            followedDriver = new StandingsItem();
        }
Example #37
0
        public void initialize()
        {
            sdk = new iRacingSDK();
            sdk.Startup();

            // check connection
            if (sdk.IsConnected())
            {
                String yaml = sdk.GetSessionInfo();

                // caridx
                Int32 start = yaml.IndexOf("DriverCarIdx: ") + "DriverCarIdx: ".Length;
                Int32 end   = yaml.IndexOf("\n", start);
                carIdx = Int32.Parse(yaml.Substring(start, end - start));

                // carname
                start = yaml.IndexOf("CarIdx: " + carIdx.ToString(), start);
                start = yaml.IndexOf("CarPath: ", start) + "CarPath: ".Length;
                end   = yaml.IndexOf("\n", start);
                if (start < 0)
                {
                    carname = "unknown";
                }
                else
                {
                    carname = yaml.Substring(start, end - start);
                }

                // track name
                start = yaml.IndexOf("TrackName: ") + "TrackName: ".Length;
                end   = yaml.IndexOf("\n", start);
                if (start < 0)
                {
                    trackname = "unknown";
                }
                else
                {
                    trackname = yaml.Substring(start, end - start);
                }

                // track length
                start = yaml.IndexOf("TrackLength: ") + "TrackLength: ".Length;
                end   = yaml.IndexOf("km\n", start);
                String dbg = yaml.Substring(start, end - start);
                trackLength = (Int32)(Single.Parse(yaml.Substring(start, end - start)) * 1000);

                // session types
                RegexOptions    options = RegexOptions.IgnoreCase | RegexOptions.Compiled;
                MatchCollection sessionNums, sessionTypes;
                Regex           optionRegex = new Regex(@"SessionNum: (\d+)", options);

                // Get matches of pattern in yaml
                sessionNums = optionRegex.Matches(yaml);

                optionRegex  = new Regex(@"SessionType: (\w+)", options);
                sessionTypes = optionRegex.Matches(yaml);

                Int32 currentSessionNum = (Int32)sdk.GetData("SessionNum");

                // Iterate matches
                for (Int32 ctr = 0; ctr < Math.Min(sessionNums.Count, sessionTypes.Count); ctr++)
                {
                    if (Int32.Parse(sessionNums[ctr].Value.Substring(12)) == currentSessionNum)
                    {
                        switch (sessionTypes[ctr].Value.Substring(13).Trim())
                        {
                        case "Practice":
                            sessiontype = iRacing.SessionTypes.practice;
                            break;

                        case "Qualify":
                            sessiontype = iRacing.SessionTypes.qualify;
                            break;

                        case "Race":
                            sessiontype = iRacing.SessionTypes.race;
                            break;

                        default:
                            sessiontype = iRacing.SessionTypes.invalid;
                            break;
                        }
                    }
                }

                // reset laptimes
                lapStartTime = (Double)sdk.GetData("ReplaySessionTime");
                lapTimeValid = false;

                // fuel consumption, last 5 lap rolling
                fuelcons    = new Single[fuelconslaps];
                fuelconsPtr = 0;

                // init timedelta
                timedelta = new TimeDelta(trackLength);
                timedelta.SaveBestLap(carIdx);
                LoadBestLap();

                init = true;
            }
            else // retry next tick
            {
                init = false;
            }
        }
Example #38
0
 IRequestResponseChannel IChannelFactory.GetChannel(IConnection connection, string peerIP, int peerPort, string bindingIP, SessionTypes sessionType, ITraceProvider traceProvider, IChannelFormatter channelFormatter)
 {
     return(new DualChannel(connection, peerIP, peerPort, bindingIP, sessionType, traceProvider, channelFormatter, _requestTimeout));
 }
Example #39
0
        public void initialize()
        {
            sdk = new iRacingSDK();
            sdk.Startup();

            // check connection
            if (sdk.IsConnected())
            {
                String yaml = sdk.GetSessionInfo();

                // caridx
                Int32 start = yaml.IndexOf("DriverCarIdx: ") + "DriverCarIdx: ".Length;
                Int32 end = yaml.IndexOf("\n", start);
                carIdx = Int32.Parse(yaml.Substring(start, end - start));

                // carname
                start = yaml.IndexOf("CarIdx: " + carIdx.ToString(), start);
                start = yaml.IndexOf("CarPath: ", start) + "CarPath: ".Length;
                end = yaml.IndexOf("\n", start);
                if (start < 0)
                    carname = "unknown";
                else
                    carname = yaml.Substring(start, end - start);

                // track name
                start = yaml.IndexOf("TrackName: ") + "TrackName: ".Length;
                end = yaml.IndexOf("\n", start);
                if (start < 0)
                    trackname = "unknown";
                else
                    trackname = yaml.Substring(start, end - start);

                // track length
                start = yaml.IndexOf("TrackLength: ") + "TrackLength: ".Length;
                end = yaml.IndexOf("km\n", start);
                String dbg = yaml.Substring(start, end - start);
                trackLength = (Int32)(Single.Parse(yaml.Substring(start, end - start)) * 1000);

                // session types
                RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.Compiled;
                MatchCollection sessionNums, sessionTypes;
                Regex optionRegex = new Regex(@"SessionNum: (\d+)", options);

                // Get matches of pattern in yaml
                sessionNums = optionRegex.Matches(yaml);

                optionRegex = new Regex(@"SessionType: (\w+)", options);
                sessionTypes = optionRegex.Matches(yaml);

                Int32 currentSessionNum = (Int32)sdk.GetData("SessionNum");

                // Iterate matches
                for (Int32 ctr = 0; ctr < Math.Min(sessionNums.Count, sessionTypes.Count); ctr++)
                {
                    if (Int32.Parse(sessionNums[ctr].Value.Substring(12)) == currentSessionNum)
                    {
                        switch (sessionTypes[ctr].Value.Substring(13).Trim())
                        {
                            case "Practice":
                                sessiontype = iRacing.SessionTypes.practice;
                                break;
                            case "Qualify":
                                sessiontype = iRacing.SessionTypes.qualify;
                                break;
                            case "Race":
                                sessiontype = iRacing.SessionTypes.race;
                                break;
                            default:
                                sessiontype = iRacing.SessionTypes.invalid;
                                break;
                        }
                    }
                }

                // reset laptimes
                lapStartTime = (Double)sdk.GetData("ReplaySessionTime");
                lapTimeValid = false;

                // fuel consumption, last 5 lap rolling
                fuelcons = new Single[fuelconslaps];
                fuelconsPtr = 0;

                // init timedelta
                timedelta = new TimeDelta(trackLength);
                timedelta.SaveBestLap(carIdx);
                LoadBestLap();

                init = true;
            }
            else // retry next tick
            {
                init = false;
            }
        }