/// <summary> /// Initializes a new instance of TcpIpSession /// </summary> /// <param name="socket">A TCP/IP socket to be used by for sending and receiving data</param> /// <param name="sessionType">The type of session this instance represents</param> internal TcpIpSession(Socket socket, SessionType sessionType) { if (socket == null) { throw new ArgumentNullException("socket"); } vSocket = socket; vSessionType = sessionType; vSyncRoot = new object(); }
public void when_a_driver_is_on_the_track_green_and_megenta_lap_time_column_colours_are_translated_into_replace_lap_time_messages(SessionType session) { In(session).OnLap(5).Assert(translator => { ReplaceDriverLapTimeMessage expected; LiveDriver driver = translator.GetDriver(1); driver.LapNumber = 5; driver.ChangeStatus(DriverStatus.OnTrack); driver.SetColumnHasValue(GridColumn.LapTime, true); driver.LastLapTime = PT(95.571, PostedTimeType.Normal, 5); // Personal best lap time. expected = new ReplaceDriverLapTimeMessage(1, PT(95.571, PostedTimeType.PersonalBest, 5)); Assert.MessagesAreEqual(expected, translator.Translate(new SetGridColumnColourMessage(1, GridColumn.LapTime, GridColumnColour.Green)) ); Assert.Equal(expected.Replacement, driver.LastLapTime); // Session best lap time. expected = new ReplaceDriverLapTimeMessage(1, PT(95.571, PostedTimeType.SessionBest, 5)); Assert.MessagesAreEqual(expected, translator.Translate(new SetGridColumnColourMessage(1, GridColumn.LapTime, GridColumnColour.Magenta)) ); Assert.Equal(expected.Replacement, driver.LastLapTime); }); }
/// <summary> /// Initialises a new instance of the <see cref="SetSessionTypeMessage"/> class and /// specifies the <see cref="AK.F1.Timing.Messages.Session.SessionType"/> and the session /// identifier. /// </summary> /// <param name="sessionType">The current /// <see cref="AK.F1.Timing.Messages.Session.SessionType"/>.</param> /// <param name="sessionId">The session identifier.</param> public SetSessionTypeMessage(SessionType sessionType, string sessionId) { Guard.NotNull(sessionId, "sessionId"); SessionType = sessionType; SessionId = sessionId; }
public void car_number_column_values_are_translated_into_set_car_number_and_or_set_status_messages(SessionType session) { In(session).Assert(translator => { CompositeMessage composite; LiveDriver driver = translator.GetDriver(1); Message actual = translator.Translate(new SetGridColumnValueMessage(1, GridColumn.CarNumber, GridColumnColour.White, "1")); Assert.IsType<CompositeMessage>(actual); composite = (CompositeMessage)actual; Assert.Equal(2, composite.Messages.Count); Assert.MessagesAreEqual(new SetDriverCarNumberMessage(1, 1), composite.Messages[0]); Assert.MessagesAreEqual(new SetDriverStatusMessage(1, DriverStatus.OnTrack), composite.Messages[1]); Assert.Equal(DriverStatus.OnTrack, driver.Status); // Change the car number. Assert.MessagesAreEqual( new SetDriverCarNumberMessage(1, 2), translator.Translate(new SetGridColumnValueMessage(1, GridColumn.CarNumber, GridColumnColour.White, "2")) ); // Change the status. Assert.MessagesAreEqual( new SetDriverStatusMessage(1, DriverStatus.InPits), translator.Translate(new SetGridColumnValueMessage(1, GridColumn.CarNumber, GridColumnColour.Red, "2")) ); Assert.Equal(DriverStatus.InPits, driver.Status); }); }
public void lap_time_column_values_are_translated_into_set_status_messages_if_the_status_has_changed(SessionType session) { In(session).Assert(translator => { SetGridColumnValueMessage message; LiveDriver driver = translator.GetDriver(1); // On track. Note that OUT is displayed when a driver exits the pit and is on thier OUT lap. message = new SetGridColumnValueMessage(1, GridColumn.LapTime, GridColumnColour.White, "OUT"); Assert.MessagesAreEqual( new SetDriverStatusMessage(1, DriverStatus.OnTrack), translator.Translate(message) ); Assert.Equal(DriverStatus.OnTrack, driver.Status); Assert.Null(translator.Translate(message)); // In pit. message = new SetGridColumnValueMessage(1, GridColumn.LapTime, GridColumnColour.White, "IN PIT"); Assert.MessagesAreEqual( new SetDriverStatusMessage(1, DriverStatus.InPits), translator.Translate(message) ); Assert.Equal(DriverStatus.InPits, driver.Status); Assert.Null(translator.Translate(message)); // Retired. message = new SetGridColumnValueMessage(1, GridColumn.LapTime, GridColumnColour.White, "RETIRED"); Assert.MessagesAreEqual( new SetDriverStatusMessage(1, DriverStatus.Retired), translator.Translate(message) ); Assert.Equal(DriverStatus.Retired, driver.Status); Assert.Null(translator.Translate(message)); }); }
public PacketAttribute(string name, PacketDirection direction, SessionType sessionType = SessionType.None, bool authRequired = true) { Name = name; Direction = direction; SessionType = sessionType; AuthRequired = authRequired; }
public void speed_capture_messages_are_translated_into_set_driver_speed_messages(SessionType session) { In(session).Assert(translator => { translator.GetDriver(1).Name = "J. BUTTON"; translator.GetDriver(2).Name = "M. SCHUMACHER"; Assert.Null(translator.Translate(new SpeedCaptureMessage(SpeedCaptureLocation.S3, new KeyValuePair<string, int>[0]))); var expected = new CompositeMessage( new SetDriverSpeedMessage(1, SpeedCaptureLocation.S3, 1), new SetDriverSpeedMessage(2, SpeedCaptureLocation.S3, 2) ); var translated = translator.Translate(new SpeedCaptureMessage(SpeedCaptureLocation.S3, new KeyValuePair<string, int>[] { new KeyValuePair<string, int>("BUT", 1), new KeyValuePair<string, int>("MSC", 2) })); var actual = Assert.IsType<CompositeMessage>(translated); Assert.Equal(expected.Messages.Count, actual.Messages.Count); for(int i = 0; i < expected.Messages.Count; ++i) { Assert.MessagesAreEqual(expected.Messages[i], actual.Messages[i]); } }); }
public AddStrategyCommand(StrategyInfo info, SessionType sessionType) { if (info == null) throw new ArgumentNullException(nameof(info)); Info = info; SessionType = sessionType; }
public ConnectionListener(int port, SessionType sessionType) { TcpListener = new TcpListener(IPAddress.Any, port); TcpListener.Start(); SessionType = sessionType; IsListening = true; }
public Session(string name, SessionType type, TcpClient client) { this.Name = name; this.InnerName = Guid.NewGuid().ToString("N"); //Generate inner name this.Type = type; m_Client = client; m_Stream = client.GetStream(); }
public Session(Socket socket, SessionType type) { Socket = socket; Type = type; IpAddress = ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(); buffer = new byte[8192]; OnConnect(); }
public void playFinishMessage(SessionType sessionType, int position, int numCars, Boolean isDisqualified) { audioPlayer.suspendPearlsOfWisdom(); if (position < 1) { Console.WriteLine("Session finished but position is < 1"); } else if (sessionType == SessionType.Race) { Boolean isLast = position == numCars; if (isDisqualified) { audioPlayer.queueClip(new QueuedMessage(sessionEndMessageIdentifier, AbstractEvent.MessageContents( Penalties.folderDisqualified), 0, null)); } else if (position == 1) { audioPlayer.queueClip(new QueuedMessage(sessionEndMessageIdentifier, AbstractEvent.MessageContents( folderWonRace), 0, null)); } else if (position < 4) { audioPlayer.queueClip(new QueuedMessage(sessionEndMessageIdentifier, AbstractEvent.MessageContents( folderPodiumFinish), 0, null)); } else if (position >= 4 && !isLast) { audioPlayer.queueClip(new QueuedMessage(sessionEndMessageIdentifier, AbstractEvent.MessageContents( Position.folderStub + position, folderFinishedRace), 0, null)); } else if (isLast) { audioPlayer.queueClip(new QueuedMessage(sessionEndMessageIdentifier, AbstractEvent.MessageContents(folderFinishedRaceLast), 0, null)); } } else { if (sessionType == SessionType.Qualify && position == 1) { audioPlayer.queueClip(new QueuedMessage(folderEndOfSessionPole, 0, null)); } else { if (position > 24) { audioPlayer.queueClip(new QueuedMessage(sessionEndMessageIdentifier, AbstractEvent.MessageContents(folderEndOfSession, Position.folderStub, QueuedMessage.folderNameNumbersStub + position), 0, null)); } else { audioPlayer.queueClip(new QueuedMessage(sessionEndMessageIdentifier, AbstractEvent.MessageContents(folderEndOfSession, Position.folderStub + position), 0, null)); } } } }
public void pit_count_columns_values_are_translated_into_set_pit_count_messages(SessionType session) { In(session).Assert(translator => { Assert.MessagesAreEqual( new SetDriverPitCountMessage(1, 2), translator.Translate(new SetGridColumnValueMessage(1, GridColumn.PitCount, GridColumnColour.White, "2")) ); }); }
internal LidgrenAvailableSession(SessionType sessionType, int currentGamerCount, string hostName, int openPrivateSlots, int openPublicSlots, SessionProperties sessionProperties, TimeSpan averageRoundtripTime) { _sessionType = sessionType; _currentGamerCount = currentGamerCount; _hostName = hostName; _openPrivateSlots = openPrivateSlots; _openPublicSlots = openPublicSlots; _sessionProperties = sessionProperties; _averageRoundtripTime = averageRoundtripTime; }
public void car_number_column_values_are_not_translated_into_set_car_number_or_set_status_messages_if_they_have_not_changed(SessionType session) { In(session).Assert(translator => { var driver = translator.GetDriver(1); driver.CarNumber = 1; driver.ChangeStatus(DriverStatus.InPits); Assert.Null(translator.Translate(new SetGridColumnValueMessage(1, GridColumn.CarNumber, GridColumnColour.Red, "1"))); }); }
public AddStrategyCommand(StrategyInfo info, StrategyContainer strategy, SessionType sessionType) { if (info == null) throw new ArgumentNullException("info"); if (strategy == null) throw new ArgumentNullException("strategy"); Info = info; Strategy = strategy; SessionType = sessionType; }
public async Task<bool> CreateP2PSession(SessionType type) { if (this.SessionListener == null) return false; if (type != SessionType.LocalNetwork) throw new NotSupportedException( "SessionType.LocalNetwork is the only SessionType supported."); this.SessionHost = true; this.SessionListener.ConnectionReceived += async (s, e) => await OnConnectionReceived(e.Socket); await this.SessionListener.BindEndpointAsync(null, Settings.tcpPort); this.InitializeNetworkInfo(); return await this.InitializeMulticast(null); }
public void translator_does_not_thrown_when_a_lap_time_colour_update_is_processed_when_no_previous_lap_time_has_been_set(SessionType session) { In(session).Assert(translator => { Message message = null; translator.Translate(new SetGridColumnValueMessage(1, GridColumn.LapTime, GridColumnColour.Red, "OUT")); Assert.DoesNotThrow(() => { message = translator.Translate(new SetGridColumnColourMessage(1, GridColumn.LapTime, GridColumnColour.White)); }); Assert.Null(message); }); }
public static IList<Question> AssignNumberToQuestion(IList<Question> questionList, SessionType type) { if (questionList == null) return null; var totalNumber = questionList.Count; for (int i = 0; i < totalNumber; i++) { questionList[i].DispalyId = i + 1; questionList[i].MaxCount = totalNumber; questionList[i].SessionMode = type; questionList[i].Points = 1; //This line will be removed, it should come from the data } return questionList; }
/// <summary> /// Loads and restores the saved session /// </summary> public static void RestoreSession(String file, SessionType type) { try { Session session = new Session(); session = (Session)ObjectSerializer.Deserialize(file, session); if (session.Files == null) session.Files = new List<string>(); session.Type = type; // set the type here... RestoreSession(file, session); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
public void when_a_driver_is_on_the_track_in_sector_1_and_the_sector_1_column_has_no_value_then_sector_2_column_clears_are_not_translated_into_set_sector_time_messages( SessionType session) { In(session).Assert(translator => { var driver = translator.GetDriver(1); driver.ChangeStatus(DriverStatus.OnTrack); driver.LapNumber = 5; driver.CurrentSectorNumber = 1; driver.SetLastSector(1, PT(23.5, PostedTimeType.Normal, 4)); driver.SetColumnHasValue(GridColumn.S1, false); Assert.Null(translator.Translate(new SetGridColumnValueMessage(1, GridColumn.S2, GridColumnColour.White, null))); }); }
/// <summary> /// Creates a grid model for the specified session type. /// </summary> /// <param name="type">The type of grid model to create.</param> /// <returns>The grid model for the specified session type.</returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// Thrown when <paramref name="type"/> is not a valid session type. /// </exception> public static GridModelBase Create(SessionType type) { switch(type) { case SessionType.None: return NullGridModel.Instance; case SessionType.Practice: return new PracticeGridModel(); case SessionType.Qually: return new QuallyGridModel(); case SessionType.Race: return new RaceGridModel(); default: throw Guard.ArgumentOutOfRange("type"); } }
public void when_a_driver_is_not_on_the_track_lap_time_column_values_are_not_translated_into_set_lap_time_messages(SessionType session) { In(session).OnLap(5).Assert(translator => { var driver = translator.GetDriver(1); var message = new SetGridColumnValueMessage(1, GridColumn.LapTime, GridColumnColour.White, "1:35.571"); // In pits. driver.ChangeStatus(DriverStatus.InPits); Assert.Null(translator.Translate(message)); // Out. driver.ChangeStatus(DriverStatus.Out); Assert.Null(translator.Translate(message)); // Retired. driver.ChangeStatus(DriverStatus.Retired); Assert.Null(translator.Translate(message)); // Stopped. driver.ChangeStatus(DriverStatus.Stopped); Assert.Null(translator.Translate(message)); }); }
public SessionInfo(Session oS) { if (oS.PathAndQuery.StartsWith("/record/", StringComparison.OrdinalIgnoreCase)) { Type = SessionType.Record; } if (oS.PathAndQuery.StartsWith("/play/", StringComparison.OrdinalIgnoreCase)) { Type = SessionType.Playback; } if (oS.PathAndQuery.StartsWith("/export/", StringComparison.OrdinalIgnoreCase)) { Type = SessionType.Export; string[] pathSegments = oS.PathAndQuery.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); UserId = pathSegments[1]; TapeId = pathSegments[2]; return; } if (Type != SessionType.None) { string path = oS.PathAndQuery; switch (path) { //#TODO: remove this case "/blank.html": //do nothing break; default: string[] pathSegments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); UserId = pathSegments[1]; TapeId = pathSegments[2]; Host = pathSegments[3]; PathAndQuery = "/" + string.Join("/", pathSegments, 4, pathSegments.Length - 4); break; } } }
/// <summary> /// This constructor is used to create a temporary session exclusivly for the purpose of listening for Discovery messages /// </summary> internal LidgrenSession(SessionType sessionType, int maxGamers, int privateReservedSlots, SessionProperties sessionProperties) { _isHost = false; _sessionType = sessionType; _sessionProperties = sessionProperties; if (maxGamers > MaximumSupportedGamersInSession) throw new CoreException("Cannot create sessions for more than " + MaximumSupportedGamersInSession + " players."); else _maxGamers = maxGamers; _privateReservedSlots = privateReservedSlots; LidgrenSessionManager.Client.Start(); //LidgrenSessionManager.Client.Connect(serverHost, LidgrenSessionManager.ServerPort); _previousSecondBytesSent += LidgrenSessionManager.Client.Statistics.SentBytes; _previousSecondBytesReceived += LidgrenSessionManager.Client.Statistics.ReceivedBytes; _clientSessionState = SessionState.Lobby; _serverSessionState = SessionState.Lobby; }
public async Task ListenForP2PSession(SessionType sessionType) { if (this.SessionListener == null) return; if (sessionType != SessionType.LocalNetwork) throw new NotSupportedException( "SessionType.LocalNetwork is the only SessionType supported."); this.SessionHost = false; this.SessionListener.ConnectionReceived += async (s, e) => this.OnMessageReceived(await this.RetrieveMessage(e.Socket)); await this.SessionListener.BindEndpointAsync(null, this.Settings.tcpPort); this.InitializeNetworkInfo(); await this.InitializeMulticast(remoteAddress => { if (this.ConnectedHost.hostTcpIP == null) { this.ConnectedHost = new P2PHost { hostTcpIP = remoteAddress }; this.OnHostAvailable(); } }); }
private LidgrenSession(string serverHost, SessionType sessionType, int maxGamers, int privateReservedSlots, SessionProperties sessionProperties, bool isHost) { _isHost = isHost; _sessionType = sessionType; _sessionProperties = sessionProperties; if (maxGamers > MaximumSupportedGamersInSession) throw new CoreException("Cannot create sessions for more than " + MaximumSupportedGamersInSession + " players."); else _maxGamers = maxGamers; _privateReservedSlots = privateReservedSlots; if (_isHost) { LidgrenSessionManager.Server.Start(); _previousSecondBytesSent = LidgrenSessionManager.Server.Statistics.SentBytes; _previousSecondBytesReceived = LidgrenSessionManager.Server.Statistics.ReceivedBytes; IdentifiedPlayer identifiedPlayer; for (int i = 0; i < 4; i++) { if (SessionManager.LocalPlayers.TryGetValue((PlayerIndex) Enum.ToObject(typeof (PlayerIndex), i), out identifiedPlayer)) { ((LidgrenIdentifiedPlayer) identifiedPlayer).SetIsHost(); break; } } } LidgrenSessionManager.Client.Start(); LidgrenSessionManager.Client.Connect(serverHost, LidgrenSessionManager.ServerPort); _previousSecondBytesSent += LidgrenSessionManager.Client.Statistics.SentBytes; _previousSecondBytesReceived += LidgrenSessionManager.Client.Statistics.ReceivedBytes; _clientSessionState = SessionState.Lobby; _serverSessionState = SessionState.Lobby; }
public void when_a_driver_is_not_on_the_track_lap_time_column_colours_are_not_translated_into_set_lap_time_messages(SessionType session) { In(session).OnLap(5).Assert(translator => { var driver = translator.GetDriver(1); var message = new SetGridColumnColourMessage(1, GridColumn.LapTime, GridColumnColour.White); driver.SetColumnHasValue(GridColumn.LapTime, true); driver.LastLapTime = PT(120.765, PostedTimeType.Normal, 1); // In pits. driver.ChangeStatus(DriverStatus.InPits); Assert.Null(translator.Translate(message)); // Out. driver.ChangeStatus(DriverStatus.Out); Assert.Null(translator.Translate(message)); // Retired. driver.ChangeStatus(DriverStatus.Retired); Assert.Null(translator.Translate(message)); // Stopped. driver.ChangeStatus(DriverStatus.Stopped); Assert.Null(translator.Translate(message)); }); }
public Session(Int32 index, List<String> files, SessionType type) { this.index = index; this.files = files; this.type = type; }
public IRutokenSession OpenRutokenSession(SessionType sessionType) { return((IRutokenSession)OpenSession(sessionType)); }
internal Session(SessionType type, string targetName, params TargetAddress[] addresses) : this(type, targetName, null, null, addresses) { }
// Event handler for the Navigating event of the root frame. // Use this handler to modify the default navigation behavior. private void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e) { // If the session type is None or New, check the navigation Uri to determine if the // navigation is a deep link or if it points to the app's main page. if (_sessionType == SessionType.None && e.NavigationMode == NavigationMode.New) { // This block will run if the current navigation is part of the app's intial launch // Keep track of Session Type if (e.Uri.ToString().Contains("DeepLink=true")) { _sessionType = SessionType.DeepLink; } else if (e.Uri.ToString().Contains("/MainPage.xaml")) { _sessionType = SessionType.Home; } } if (e.NavigationMode == NavigationMode.Reset) { // This block will execute if the current navigation is a relaunch. // If so, another navigation will be coming, so this records that a relaunch just happened // so that the next navigation can use this info. _wasRelaunched = true; } else if (e.NavigationMode == NavigationMode.New && _wasRelaunched) { // This block will run if the previous navigation was a relaunch _wasRelaunched = false; if (e.Uri.ToString().Contains("DeepLink=true")) { // This block will run if the launch Uri contains "DeepLink=true" which // was specified when the secondary tile was created in MainPage.xaml.cs _sessionType = SessionType.DeepLink; // The app was relaunched via a Deep Link. // The page stack will be cleared. } else if (e.Uri.ToString().Contains("/MainPage.xaml")) { // This block will run if the navigation Uri is the main page if (_sessionType == SessionType.DeepLink) { // When the app was previously launched via Deep Link and relaunched via Main Tile, we need to clear the page stack. _sessionType = SessionType.Home; } else { if (!_mustClearPagestack) { //The app was previously launched via Main Tile and relaunched via Main Tile. Cancel the navigation to resume. e.Cancel = true; RootFrame.Navigated -= ClearBackStackAfterReset; } } } _mustClearPagestack = false; } }
private void GetParametersToNegotiate(TextBuffer parameters, KeyUsagePhase phase, SessionType sessionType) { PropertyInfo[] properties = GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var propInfo in properties) { ProtocolKeyAttribute attr = (ProtocolKeyAttribute)Attribute.GetCustomAttribute(propInfo, typeof(ProtocolKeyAttribute)); if (attr != null) { object value = propInfo.GetGetMethod(true).Invoke(this, null); if (attr.ShouldTransmit(value, propInfo.PropertyType, phase, sessionType == SessionType.Discovery)) { parameters.Add(attr.Name, ProtocolKeyAttribute.GetValueAsString(value, propInfo.PropertyType)); _negotiatedParameters.Add(attr.Name, ""); } } } }
public override void Update(ConfigurationSection rootNode, API api) { SessionType type = (api.FindModule("SessionTimer") as SessionTimerModule).SessionType; if (type != SessionType.LapRace && type != SessionType.TimeRace) { return; } if (liveStandings == null) { liveStandings = api.FindModule("LiveStandings") as LiveStandingsModule; } if (drivers == null) { drivers = api.FindModule("DriverModule") as DriverModule; } int driversCount = drivers.DriversCount; int notStarters = liveStandings.Items.Count(d => d.Dns); if (lastDriversCount != driversCount) { matrix = new double[driversCount, driversCount + 1]; exponentialSoF = new double[driversCount]; expectedScores = new double[driversCount]; fudgeFactors = new double[driversCount]; } for (int i = 0; i < driversCount; i++) { LiveStandingsItem driverOpponent = liveStandings.FindDriverByPosNL(i + 1); if (driverOpponent == null) { return; } matrix[i, 0] = driverOpponent.Driver.IRating; exponentialSoF[i] = Math.Exp(-driverOpponent.Driver.IRating / log); fudgeFactors[i] = driverOpponent.Dns ? 0 : (((driversCount - (notStarters / 2D)) / 2 - driverOpponent.Position) / 100); for (int j = 1; j <= driversCount; j++) { LiveStandingsItem driverSelf = liveStandings.FindDriverByPosNL(j); if (driverSelf == null) { return; } matrix[i, j] = calcMatrixEntry(driverOpponent.Driver.IRating, driverSelf.Driver.IRating); } } changeStarters.Clear(); expChangeNonStarters.Clear(); foreach (LiveStandingsItem driver in liveStandings.Items) { int index = driver.Position - 1; double expectedScore = -0.5D; for (int i = 1; i <= driversCount; i++) { expectedScore += matrix[index, i]; } expectedScores[index] = expectedScore; if (driver.Dns) { expChangeNonStarters.Add(expectedScore); } } foreach (LiveStandingsItem driver in liveStandings.Items) { if (!driver.Dns) { int i = driver.Position - 1; double change = (driversCount - driver.Position - expectedScores[i] - fudgeFactors[i]) * 200D / (driversCount - notStarters); changeStarters.Add(change); driver.IRatingChange = (int)change; } } foreach (LiveStandingsItem driver in liveStandings.Items) { if (driver.Dns) { int i = driver.Position - 1; double sum = 0D; foreach (double d in changeStarters) { sum += d; } double avg = 0; foreach (double d in expChangeNonStarters) { avg += d; } avg /= expChangeNonStarters.Count; double change = (-sum) / notStarters * expectedScores[i] / avg; driver.IRatingChange = (int)change; } } lastDriversCount = driversCount; }
private SessionType Validate(SessionType obj) { List <int> CommonLst = new List <int>(); List <int> temp = new List <int>(); if (obj.ConType == "P") { for (int i = 0; i < obj.SessionLst.Count; i++) { List <SessionLecturer> lecLst = new SessionLecturerAPI().GetAll(obj.SessionLst[i].ObjId); for (int j = 0; j < lecLst.Count; j++) { CommonLst.Add(lecLst[j].RefLecturerId); } } if (CommonLst.Count != CommonLst.Distinct().ToList().Count) { obj.ValidationErrors.Add("Same lecturer(s) cannot be appeared in parallel sessions"); return(obj); } CommonLst.Clear(); //group validation for (int i = 0; i < obj.SessionLst.Count; i++) { if (obj.SessionLst[i].Tag == "PRACTICAL") { CommonLst.Add(obj.SessionLst[i].RefSubGroupId); } else { List <StudentSubGroup> sgLst = new StudentSubGroupAPI().GetSubGoups(obj.SessionLst[i].RefGroupId); foreach (StudentSubGroup item in sgLst) { CommonLst.Add(item.ObjId); } } } if (CommonLst.Count != CommonLst.Distinct().ToList().Count) { obj.ValidationErrors.Add("Cannot have common Student Group/Sub Group in parallel sessions"); return(obj); } CommonLst.Clear(); for (int i = 0; i < obj.SessionLst.Count; i++) { temp = GetConnectedSessions(obj.SessionLst[i].ObjId, "C"); for (int j = 0; j < temp.Count; j++) { CommonLst.Add(temp[j]); } } if (CommonLst.Count != CommonLst.Distinct().ToList().Count) { obj.ValidationErrors.Add("Sessions already incuded with another consecutive session"); return(obj); } CommonLst.Clear(); for (int i = 0; i < obj.SessionLst.Count; i++) { temp = GetConnectedSessions(obj.SessionLst[i].ObjId, "O"); for (int j = 0; j < temp.Count; j++) { CommonLst.Add(temp[j]); } } if (CommonLst.Count != CommonLst.Distinct().ToList().Count) { obj.ValidationErrors.Add("Sessions already incuded with another non overlaping session"); return(obj); } return(obj); } else { for (int i = 0; i < obj.SessionLst.Count; i++) { if (obj.ConType == "C") { temp = GetConnectedSessions(obj.SessionLst[i].ObjId, "P"); } else if (obj.ConType == "P") { temp = GetConnectedSessions(obj.SessionLst[i].ObjId, "C"); } else if (obj.ConType == "O") { temp = GetConnectedSessions(obj.SessionLst[i].ObjId, "P"); } for (int j = 0; j < temp.Count; j++) { CommonLst.Add(temp[j]); } } if (CommonLst.Count != CommonLst.Distinct().ToList().Count) { String info = ""; if (obj.ConType == "C") { info = "Sessions already incuded with another parallel session"; } else if (obj.ConType == "P") { info = "Sessions already incuded with another consecutive session"; } else if (obj.ConType == "O") { info = "Sessions already incuded with another non overlaping session"; } obj.ValidationErrors.Add(info); return(obj); } else { return(obj); } } }
private static LidgrenSession Create(string serverHost, SessionType sessionType, int maxGamers, int privateReservedSlots, SessionProperties sessionProperties, bool isHost) { var session = new LidgrenSession(serverHost, sessionType, maxGamers, privateReservedSlots, sessionProperties, isHost); return(session); }
public SessionInfo() { Type = SessionType.SSH; Host = "localhost"; External = false; }
/// <summary> /// Creates a new instance of a Session /// </summary> /// <param name="socket">Socket connection of the session</param> public Session(Socket socket, SessionType type) { _socket = socket; _type = type; }
/// <summary> /// To be called by view when ready /// </summary> public async Task <TerminalResponse> StartShellProcessAsync(ShellProfile shellProfile, TerminalSize size, SessionType sessionType, string termState) { if (!_requireShellProcessStart && !string.IsNullOrEmpty(termState)) { OutputReceived?.Invoke(this, Encoding.UTF8.GetBytes(termState)); } _trayProcessCommunicationService.SubscribeForTerminalOutput(Id, t => OutputReceived?.Invoke(this, t)); if (_requireShellProcessStart) { var response = await _trayProcessCommunicationService .CreateTerminalAsync(Id, size, shellProfile, sessionType).ConfigureAwait(false); if (response.Success) { _fallbackTitle = response.Name; SetTitle(_fallbackTitle); } return(response); } else { return(await _trayProcessCommunicationService.PauseTerminalOutputAsync(Id, false)); } }
/// <summary> /// Sends a Find query on the network interface to look for AvailableSession instances asynchrnously /// </summary> /// <param name="sessionType">The SessionType we're looking for</param> /// <param name="maxLocalPlayers">The Maximum local players that can be added to the session used to filter sessions that have a limited number of opened public slots</param> /// <param name="sessionProperties">The SessionProperties that will be used to filter query results. Can be null</param> public abstract void FindSessions(SessionType sessionType, int maxLocalPlayers, SessionProperties sessionProperties);
public static async Task <OAuthAccessTokenTestResult> TestAccessTokenAsync(string accessToken, SessionType sessionType = SessionType.Prod) { //var url = // string.Format("{0}/api/v2/auth_test", // sessionType == SessionType.Sandbox ? Com.Alibaba.Config.RequestUriRootSandbox : Com.Alibaba.Config.RequestUriRoot); //var data = new //{ // access_token = accessToken //}; //return await CommonJsonSend.SendAsync<OAuthAccessTokenTestResult>(null, url, data, CommonJsonSendType.POST); throw new NotImplementedException("1688 没有测试令牌有效性的Api"); }