// 로그인 시도 public void GetLogin(string _id, string _password) { // 로그인 캔버스에서 로딩 캔버스로 전환 GameObject.Find("UIManager").GetComponent <SceneChange>().I_LoginToLoading(); // 아이디 비밀번호 업데이트 m_userID = _id; m_password = _password; m_proxy.RequestLogin(HostID.HostID_Server, RmiContext.SecureReliableSend, m_userID, m_password); if (m_state == MyState.Disconnected) // 연결되지 않은상태이면 { var connectParam = new NetConnectionParam(); // 연결은 위한 config 작성 connectParam.protocolVersion = new Guid(); connectParam.protocolVersion.Set(Version); // 프로토콜 버전은 서버와 동일하게 connectParam.serverIP = "localhost"; // 서버 IP connectParam.serverPort = ServerPort; // 서버 포트 값 m_Client.Connect(connectParam); // 연결 시도. m_state = MyState.Connecting; // 연결 중으로 변경. } else { //Debug.Log("서버 연결 오류"); } }
/// <summary> /// Initializes a new instance of the <see cref="BinaryUDPPackageReader"/> class. /// </summary> /// <param name="port">The port.</param> /// <param name="trace">The trace.</param> public BinaryUDPPackageReader(IUADecoder uaDecoder, int port, Action <string> trace, IConsumerViewModel viewModel) : base(uaDecoder) { State = new MyState(this); m_Trace = trace; m_UDPPort = port; m_ViewModel = viewModel; }
IEnumerator HandleJump(MyState state) { gravity = 0.7f; while (true) { if (state == MyState.STATE_DIVING) { break; } velocity.y = velocity.y + gravity; transform.position = velocity; if (velocity.y < 1f) { break; } gravity = gravity - 0.1f; yield return(new WaitForSeconds(0.05f)); } gravity = 0; velocity.y = 1f; transform.position = velocity; GetComponent <MyAction>().setActionType(MyState.STATE_STANDING); yield return(null); }
public void Gets() { var initialState = new MyState { Property1 = 42, Property2 = "Hello" }; var stateMonad1 = State <MyState> .Return(10.1); var stateMonad2 = stateMonad1.Gets(state => state.Property1); var stateMonad3 = stateMonad1.Gets(state => state.Property2); var newState1 = stateMonad2.RunState(initialState); var a1 = newState1.Item1; var s1 = newState1.Item2; Assert.That(a1, Is.EqualTo(initialState.Property1)); Assert.That(s1, Is.SameAs(initialState)); var newState2 = stateMonad3.RunState(initialState); var a2 = newState2.Item1; var s2 = newState2.Item2; Assert.That(a2, Is.EqualTo(initialState.Property2)); Assert.That(s2, Is.SameAs(initialState)); }
/// <summary> /// Since our conditions implement a behavior (interface) and not a state (base class), serialization must be done /// manually. /// </summary> public void ReadXml(XmlReader reader) { var name = reader.GetAttribute("Name"); var entry = reader.GetAttribute("Entry"); var myState = reader.GetAttribute("MyState"); var enabled = reader.GetAttribute("Enabled"); reader.Read(); Name = name; int outEntry; if (!int.TryParse(entry, out outEntry)) { Log.Gui( string.Format( "WARNING: Unable to load item \"{0}\" because the entry id is missing. This is due to having an older version of the Paws-Items.xml settings file. Please either delete the Paws-Items.xml file under your settings folder, or re-add items using the Items tab in the Paws user interface.", name)); return; } Entry = outEntry; MyState outMyState; Enum.TryParse(myState, out outMyState); MyState = outMyState; Enabled = bool.Parse(enabled); var serializer = new XmlSerializer(Conditions.GetType()); Conditions = (List <ItemCondition>)serializer.Deserialize(reader); reader.ReadEndElement(); }
/// <summary> /// Starts the cooldown. /// </summary> private void StartCooldown() { myState = MyState.Cooldown; cooldownCounter = cooldown; cooldownIcon.gameObject.SetActive(true); cooldownText.gameObject.SetActive(true); }
public void Specifying_an_event_activity_with_data() { _instance = new MyState(); _top = AutomatonymousStateMachine <MyState> .New(builder => builder .State("Greeted", out TopGreeted) .Event("Initialized", out TopInitialized) .InstanceState(b => b.Top) .During(builder.Initial) .When(TopInitialized, b => b.TransitionTo(TopGreeted)) ); _bottom = AutomatonymousStateMachine <MyState> .New(builder => builder .State("Ignored", out BottomIgnored) .Event("Initialized", out BottomInitialized) .InstanceState(b => b.Bottom) .During(builder.Initial) .When(BottomInitialized, b => b.TransitionTo(BottomIgnored)) ); _top.RaiseEvent(_instance, TopInitialized, new Init { Value = "Hello" }).Wait(); _bottom.RaiseEvent(_instance, BottomInitialized, new Init { Value = "Goodbye" }).Wait(); }
/// <summary> /// Update this instance. /// </summary> void Update() { switch (myState) { case MyState.Cooldown: // Wait for cooldown end if (counter > 0f) { counter -= Time.deltaTime; } else { counter = 0f; myState = MyState.WaitForDamage; } break; case MyState.Clouded: // Make cloud to get invisible all nearest units if (counter > 0f) { counter -= Time.deltaTime; } else { counter = cooldown; myState = MyState.Cooldown; } break; } }
public async Task HandleInstallUpdateDataAsync(InstalledAppInstance installedApp, dynamic data, bool shouldSubscribeToEvents = true) { _ = installedApp ?? throw new ArgumentNullException(nameof(installedApp)); var state = await stateManager.GetStateAsync(installedApp.InstalledAppId).ConfigureAwait(false); if (state == null) { state = new MyState() { InstalledAppId = installedApp.InstalledAppId }; } state.IsAppEnabled = bool.Parse(data.installedApp.config.isAppEnabled[0].stringConfig.value.Value); var loadTasks = new Task[] { LoadLightSwitchesAsync(installedApp, state, data, shouldSubscribeToEvents) }; Task.WaitAll(loadTasks); Logger.LogDebug($"MyState: {state.ToJson()}"); await stateManager.StoreStateAsync(installedApp.InstalledAppId, state).ConfigureAwait(false); Logger.LogInformation($"Updated config for installedApp: {installedApp.InstalledAppId}..."); }
/// <summary> /// Sets visible defend flag. /// </summary> /// <param name="enabled">If set to <c>true</c> enabled.</param> public void SetVisible(bool enabled) { if (enabled == true) { if (myState == MyState.Inactive) { buildingPlace = GetComponentInParent <BuildingPlace>(); tower = buildingPlace.GetComponentInChildren <Tower>(); // Show defend flag activeDefendFlag = Instantiate(defendFlagPrefab); activeDefendFlag.transform.position = transform.position; myState = MyState.Active; } } else { if (myState == MyState.Active) { myState = MyState.Inactive; // Hide defense range tower.ShowRange(false); // Hide flag Destroy(activeDefendFlag); } } }
private void EndTcpAcceptConnection(IAsyncResult ar) { TcpClient client = null; NetworkStream stream = null; try { client = _tcpListener.EndAcceptTcpClient(ar); lock (_tcpListener) { _hasActiveTcpListener = false; StartTcpAcceptConnection(); } stream = client.GetStream(); MyState state = new MyState { Client = client, Stream = stream, Buffer = new byte[2], BytesToReceive = 2, TimeRemaining = Timeout }; state.Timer = new Timer(TcpTimedOut, state, state.TimeRemaining, System.Threading.Timeout.Infinite); state.AsyncResult = stream.BeginRead(state.Buffer, 0, 2, EndTcpReadLength, state); } catch (Exception e) { HandleTcpException(e, stream, client); } }
private void TcpTimedOut(object timeoutState) { MyState state = timeoutState as MyState; if ((state != null) && (state.AsyncResult != null) && !state.AsyncResult.IsCompleted) { try { if (state.Stream != null) { state.Stream.Close(); } } catch {} try { if (state.Client != null) { state.Client.Close(); } } catch {} } }
internal BinaryUDPPackageWriter(string remoteHostName, int remotePort) { UDPMessageHandlerSemanticEventSource.Log.EnteringMethod(nameof(BinaryUDPPackageWriter), $"{nameof(BinaryUDPPackageWriter)}(RemoteHostName={remoteHostName},RemotePort={remotePort})"); State = new MyState(this); m_RemoteHostName = remoteHostName; m_remotePort = remotePort; }
public BinaryUDPPackageWriter(string remoteHostName, int port, IUAEncoder uaEncoder) : base(uaEncoder, MessageLengthFieldTypeEnum.TwoBytes) { State = new MyState(); m_RemoteHostName = remoteHostName; m_Port = port; }
public void StopJob(Guid jobID) { //Look for the job in the service wide container MyState state = GetStateFromServiceWideContainer(jobID); state.Abort = true; }
void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "FeiZao") { isPeng = true; //coll.gameObject.SendMessage("ApplyDamage", 10); //dir = this.transform.position - coll.transform.position; //int power = GetComponent<Hero> ().MyPower; this.rigidbody2D.drag = 5.0f; GameObject boom = GameObject.Instantiate(myBoom, this.transform.position, Quaternion.identity) as GameObject; currentState = MyState.pengzhuan; } if (coll.gameObject.tag == "Hero") { if (coll.gameObject.GetComponent <Hero>().IsChuQuan) { if (this.gameObject.name == "hero_3(Clone)") { GameObject boom = GameObject.Instantiate(myBoom, this.transform.position, Quaternion.identity) as GameObject; currentState = MyState.pengzhuan; Destroy(coll.gameObject); Destroy(this.gameObject); } } } }
/// <summary> /// Stops the cooldown. /// </summary> private void StopCooldown() { myState = MyState.Active; cooldownCounter = 0f; cooldownIcon.gameObject.SetActive(false); cooldownText.gameObject.SetActive(false); }
public void Action(MyState _CurState) { if (OnAction != null) { OnAction(_CurState); } }
// Update is called once per frame void Update() { switch (myState) { case MyState.CoolDown: //等待冷却结束 if (counter > 0f) { counter -= Time.deltaTime; } else { counter = 0f; myState = MyState.WaitForDamage; } break; case MyState.Cloud: if (counter > 0f) { counter -= Time.deltaTime; } else { counter = coolDown; myState = MyState.CoolDown; } break; } }
public void Exit(MyState _from, MyState _to) { if (OnExit != null) { OnExit(_from, _to); } }
public void PlaceInBoat() { gameObject.transform.position = myMarkInBoat.transform.position; gameObject.transform.parent = GameObject.FindWithTag ("Boat").transform; inBoat = true; my_state = MyState.InBoat; }
public void Enter(MyState _from, MyState _to) { if (OnEnter != null) { OnEnter(_from, _to); } }
public void PlaceInBoat() { gameObject.transform.position = myMarkInBoat.transform.position; gameObject.transform.parent = GameObject.FindWithTag("Boat").transform; inBoat = true; my_state = MyState.InBoat; }
//#SHOW02_1 Logon GUI code here. No work yet. void OnGUI() { if (m_state == MyState.Disconnected || m_state == MyState.Connecting) { GUI.Label(new Rect(10, 10, 300, 30), "## ProudNet Sample ##"); GUI.Label(new Rect(10, 30, 300, 30), "Enter your ID, password here."); m_userID = GUI.TextField(new Rect(10, 60, 200, 30), m_userID); m_password = GUI.TextField(new Rect(10, 90, 200, 30), m_password); if (m_state == MyState.Disconnected) { if (GUI.Button(new Rect(10, 130, 100, 20), "Login!")) { // #SHOW09 Connection request var connectParam = new NetConnectionParam(); connectParam.protocolVersion = new Guid(); connectParam.protocolVersion.Set(Version); connectParam.serverIP = "localhost"; connectParam.serverPort = ServerPort; m_netClient.Connect(connectParam); m_state = MyState.Connecting; } } if (m_state == MyState.Connecting) { GUI.Button(new Rect(10, 130, 100, 20), "Connecting..."); } } }
private void init(LiveSplitState state, USB2SnesW.USB2SnesW usb2snesw) { _state = state; _mystate = MyState.NONE; _proto_state = ProtocolState.NONE; _settings = new ComponentSettings(); _model = new TimerModel() { CurrentState = _state }; _state.RegisterTimerModel(_model); _stateChanged = false; _splits = null; _inTimer = false; _config_checked = false; _valid_config = false; _update_timer = new Timer() { Interval = 1000 }; _update_timer.Tick += (sender, args) => UpdateSplitsWrapper(); _update_timer.Enabled = true; _state.OnReset += _state_OnReset; _state.OnStart += _state_OnStart; HorizontalWidth = 3; VerticalHeight = 3; _usb2snes = usb2snesw; }
private CyptroUpdater(MyState state) { foreach (var pair in state.Passwords) { _passwords.Add(pair.Key, pair.Value); } }
/// <summary> /// Stops the cooldown. /// </summary> private void StopCooldown() { myState = MyState.Active; enabledIcon.SetActive(true); cooldownIcon.gameObject.SetActive(false); cooldownText.gameObject.SetActive(false); }
public string EndLengthyProcedure(IAsyncResult call) { //Remove from service wide container MyState ms = (MyState)call.AsyncState; return(ms.asyncStub.EndInvoke(call)); }
private void Init(LiveSplitState state, USB2SnesW.USB2SnesW usb2snesw) { _usb2snes = usb2snesw; _mystate = MyState.NONE; _proto_state = ProtocolState.NONE; _stateChanged = false; _state = state; _settings = new ComponentSettings(); _model = new TimerModel() { CurrentState = _state }; _state.RegisterTimerModel(_model); _state.OnReset += _state_OnReset; _state.OnStart += _state_OnStart; _update_timer = new Timer() { Interval = 1000 }; _update_timer.Tick += (sender, args) => UpdateSplitsWrapper(); _update_timer.Enabled = true; _fs_watcher = new FileSystemWatcher(); _fs_watcher.Changed += async(sender, args) => { await Task.Delay(200); _do_reload = true; }; _splits = new List <Split>(); _inTimer = false; HorizontalWidth = 3; VerticalHeight = 3; }
public void ShowReadyForConnection() { ShowFirstScrollView(); BeginHorCentered(); GUILayout.Label("<size=20><b>Ready for connection with " + connectedDeviceName + "</b></size>"); EndHorCentered(); BeginHorCentered(); GUILayout.Label("<size=12>When you press play, a connection with the device will be established.</size>"); EndHorCentered(); EndFirstScrollView(); BeginHorCentered(); if (GUILayout.Button("Choose other device", GUILayout.Width(150))) { ConnectionSettings.RemoteSettings(); ConnectionController.CloseConnection(); myState = MyState.refreshing; DiscoverDevices(); } EndHorCentered(); GUILayout.EndVertical(); }
/// <summary> /// Initializes a new instance of the <see cref="BinaryUDPPackageReader"/> class. /// </summary> /// <param name="port">The port.</param> /// <param name="trace">The trace.</param> public BinaryUDPPackageReader(IUADecoder uaDecoder, int port, Action<string> trace, IConsumerViewModel viewModel) : base(uaDecoder) { State = new MyState(this); m_Trace = trace; m_UDPPort = port; m_ViewModel = viewModel; }
internal BinaryUDPPackageWriter(string remoteHostName, int remotePort, IUAEncoder uaEncoder) : base(uaEncoder, MessageLengthFieldTypeEnum.TwoBytes) { UDPMessageHandlerSemanticEventSource.Log.EnteringMethod(nameof(BinaryUDPPackageWriter), $"{nameof(BinaryUDPPackageWriter)}(RemoteHostName={remoteHostName},RemotePort={remotePort})"); State = new MyState(this); m_RemoteHostName = remoteHostName; m_remotePort = remotePort; }
public void PlaceInBoat() { //Debug.Log ("PLACE CABBAGE IN BOAT"); gameObject.transform.position = myMarkInBoat.transform.position; gameObject.transform.parent = GameObject.FindWithTag ("Boat").transform; inBoat = true; //transform.parent = GameObject.FindWithTag ("Boat").transform; my_state = MyState.InBoat; //Debug.Log ("Cabbage state = "+my_state.ToString()); }
public BinaryUDPPackageWriter(string remoteHostName, int remotePort, Action<string> trace, IProducerViewModel ViewModel, IUAEncoder uaEncoder) : base(uaEncoder, MessageLengthFieldTypeEnum.TwoBytes) { m_Trace = trace; m_ViewModel = ViewModel; State = new MyState(this); m_RemoteHostName = remoteHostName; m_remotePort = remotePort; ViewModel.BytesSent = 0; ViewModel.PackagesSent = 0; trace("Created BinaryUDPPackageWriter"); }
public void ChangeState(MyState newState) { if (newState == null) { return; } m_cPreState = m_cCurrentState; m_cCurrentState.Exit(m_cOwner); m_cCurrentState = newState; m_cCurrentState.Enter(m_cOwner); }
public void PlaceOnShore() { if (inBoat) { inBoat = false; transform.parent = null; if (BoatScript.boat_state == BoatState.EastBank) { gameObject.transform.position = myMarkOnEastBank; my_state = MyState.EastBank; //Debug.Log ("cabbage state = " + CabbageScript.my_state.ToString () + "wolf state " + WolfScript.my_state.ToString () + " chx state " + ChickenScript.my_state.ToString () + " player state " + PlayerScript.my_state.ToString() + "boat state" + BoatScript.boat_state.ToString()); } else if (BoatScript.boat_state == BoatState.WestBank) { gameObject.transform.position = myMarkOnWestBank; my_state = MyState.WestBank; //Debug.Log ("cabbage state = " + CabbageScript.my_state.ToString () + "wolf state " + WolfScript.my_state.ToString () + " chx state " + ChickenScript.my_state.ToString () + " player state " + PlayerScript.my_state.ToString() + "boat state" + BoatScript.boat_state.ToString()); } } }
public static void Main(string[] args) { MyState myState = new MyState (); myState.MyProperty = 35; //Expression<Func<MyState, long>> GetMyPropertyExpression = p => p.MyProperty; ParameterExpression param = Expression.Parameter (typeof(MyState), "$val"); Expression GetMyPropertyExpression = Expression.Property (param, "MyProperty"); Expression expr = Expression.Equal (GetMyPropertyExpression, Expression.Add ( Expression.Constant ((long)17), Expression.Constant ((long)18))); //var block = Expression.Block (typeof(bool), new ParameterExpression[] { variable }, expr); Console.WriteLine (expr.ToString ()); expr = expr.Reduce (); Console.WriteLine (expr.ToString ()); var compiled = Expression.Lambda<Func<MyState, bool>> (expr, new ParameterExpression[] { param }).Compile (); Console.WriteLine (compiled (myState)); /* //ConstExpression<DataBoolean> expr1 = new ConstExpression<DataBoolean> (true); ConstExpression expr1 = new ConstExpression (new DataString ("aaa")); ConstExpression expr2 = new ConstExpression (new DataString ("bbb")); Expression exprAdd = ExpressionOperationEngine.Get ().Operate (Operator.Add, expr1, expr2); Console.WriteLine (exprAdd.GetResultDataType ()); //var exprR = ExpressionTree.ConstructOperation (Operation.Not, expr1); //Console.WriteLine (exprR.EvaluateAsData (null).ToDataString ().ToString ()); Console.ReadLine (); */ }
public void MountBoat() { beStill = true; noMouse = true; startMounting = true; GetComponent<CapsuleCollider> ().isTrigger = true; my_state = MyState.InBoat; // transform.position = new Vector3(transform.position.x, transform.position.y+5.0f, transform.position.z); }
void InitSetup() { while (myState != MyState.READY) { Thread.Sleep(2000); try { Invoke((MethodInvoker)delegate { switch (myState) { case MyState.FIRST_LOAD: webBrowser1.Document.Window.ScrollTo(3000, 0); myState = MyState.TO_LOGIN; break; case MyState.TO_LOGIN: if (webBrowser1.DocumentText.Contains("Welcome,")) { webBrowser1.Document.Window.ScrollTo(3000, 0); myState = MyState.READY; StartButton.Enabled = true; printText("Login Success!\n\nPress START to extract data of stocks."); cookies = GetCookies(); } break; } }); } catch { } } }
public bool isInState(MyState state) { return true; }
public MyDependencyResolver() { MyState = new MyState(); }
public static async Task<bool> UseEligibleItems(MyState myState) { var eligibleItems = Items .Where(o => o.MyState == myState && o.Enabled); foreach (var item in eligibleItems) { if (await UseItem(item)) return true; } return false; }
public override void UpdateBeforeSimulation() { base.UpdateBeforeSimulation(); if (!MySession.Static.IsScenario) return; if (!Sync.IsServer) return; if (MySession.Static.OnlineMode == MyOnlineModeEnum.OFFLINE)//!Sync.MultiplayerActive) { if (m_gameState == MyState.Loaded) { m_gameState = MyState.Running; ServerStartGameTime = DateTime.UtcNow; } return; } switch (m_gameState) { case MyState.Loaded: if (MySession.Static.OnlineMode != MyOnlineModeEnum.OFFLINE && MyMultiplayer.Static == null) { m_bootUpCount++; if (m_bootUpCount > 10)//because MyMultiplayer.Static is initialized later than this part of game { //network start failure - trying to save what we can :-) MyPlayerCollection.RequestLocalRespawn(); m_gameState = MyState.Running; return; } } if (MySandboxGame.IsDedicated) { ServerPreparationStartTime = DateTime.UtcNow; MyMultiplayer.Static.ScenarioStartTime = ServerPreparationStartTime; m_gameState = MyState.Running; return; } if (MySession.Static.OnlineMode == MyOnlineModeEnum.OFFLINE || MyMultiplayer.Static != null) { if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Scenario = true; MyMultiplayer.Static.ScenarioBriefing = MySession.Static.GetWorld().Checkpoint.Briefing; } MyGuiScreenScenarioMpServer guiscreen = new MyGuiScreenScenarioMpServer(); guiscreen.Briefing = MySession.Static.GetWorld().Checkpoint.Briefing; MyGuiSandbox.AddScreen(guiscreen); m_playersReadyForBattle.Add(MySteam.UserId); m_gameState = MyState.JoinScreen; } break; case MyState.JoinScreen: break; case MyState.WaitingForClients: // Check timeout TimeSpan currenTime = MySession.Static.ElapsedPlayTime; if (AllPlayersReadyForBattle() || (LoadTimeout>0 && currenTime - m_startBattlePreparationOnClients > TimeSpan.FromSeconds(LoadTimeout))) { StartScenario(); foreach (var playerId in m_playersReadyForBattle) { if (playerId != MySteam.UserId) MySyncScenario.StartScenarioRequest(playerId, ServerStartGameTime.Ticks); } } break; case MyState.Running: break; } }
internal void PrepareForStart() { Debug.Assert(Sync.IsServer); m_gameState = MyState.WaitingForClients; m_startBattlePreparationOnClients = MySession.Static.ElapsedPlayTime; var onlineMode = GetOnlineModeFromCurrentLobbyType(); if (onlineMode != MyOnlineModeEnum.OFFLINE) { m_waitingScreen = new MyGuiScreenScenarioWaitForPlayers(); MyGuiSandbox.AddScreen(m_waitingScreen); ServerPreparationStartTime = DateTime.UtcNow; MyMultiplayer.Static.ScenarioStartTime = ServerPreparationStartTime; MySyncScenario.PrepareScenarioFromLobby(ServerPreparationStartTime.Ticks); } else { StartScenario(); } }
private void StartScenario() { if (Sync.IsServer) { ServerStartGameTime = DateTime.UtcNow; } if (m_waitingScreen != null) { MyGuiSandbox.RemoveScreen(m_waitingScreen); m_waitingScreen = null; } m_gameState = MyState.Running; m_startBattleTime = MySession.Static.ElapsedPlayTime; MyPlayerCollection.RequestLocalRespawn(); }
void Start() { ///////myMarkInBoat = GameObject.FindWithTag("wolf_mark_in_boat").transform.position; myMarkOnEastBank = gameObject.transform.position; myMarkOnWestBank = GameObject.FindWithTag("wolf_mark_west").transform.position; my_state = MyState.EastBank; //base.GetMyState(); }
public void Reset(string whatev) { my_state = MyState.EastBank; inBoat = false; }
//Single Thread Recurring Function void ReadStockFromStockQueue() { if (stockAddressQueue.IsEmpty) { printText("Extract Completed! Total files = " + CompleteFileList.Count); myState = MyState.READY; SaveAllFiles(CompleteFileList); return; } if (!stockAddressQueue.IsEmpty && stockAddressQueue.TryDequeue(out currStockCode)) { int counter = 0; bool extractSuccess = false; currStockNum++; printText("Reading... (" + currStockNum + "/" + totalStockNum + ")"); webBrowser1.DocumentText = ""; webBrowser1.Navigate("http://www.shareinvestor.com/fundamental/events_calendar.html#/?type=events_historical&page=" + currStockCode); while (!extractSuccess && counter <= 3) { Thread.Sleep(2000); Invoke((MethodInvoker)delegate { counter++; extractSuccess = ExtractInfo(webBrowser1.DocumentText); if (extractSuccess) printText("Extract Success! (" + currStockNum + "/" + totalStockNum + ")"); else printText("Extract Fail! Retry " + counter + "..."); }); } ReadStockFromStockQueue(); } }
public void ResetPlayerFunctionality() { inBoat = false; beStill = false; startDismounting = true; GetComponent<CapsuleCollider> ().isTrigger = false; transform.parent = null; noMouse = false; if (BoatScript.boat_state == BoatState.EastBank) { my_state = MyState.EastBank; GameObject.FindGameObjectWithTag("EastBankBoatSpot").GetComponent<Collider>().enabled = false; GameObject.FindGameObjectWithTag("WestBankBoatSpot").GetComponent<Collider>().enabled = true; } else if (BoatScript.boat_state == BoatState.WestBank) { my_state = MyState.WestBank; GameObject.FindGameObjectWithTag("EastBankBoatSpot").GetComponent<Collider>().enabled = true; GameObject.FindGameObjectWithTag("WestBankBoatSpot").GetComponent<Collider>().enabled = false; } }
private bool Equals(MyState other) { return string.Equals(this.Name, other.Name); }
public void TestInitialGenericSpState() { TestHelpers.CatchUnexpected(() => { MyDataClass dataClass = new MyDataClass(); // This would normally be the main superstate which includes all other states cascading within it's and it's children's constructors MyState sParent = new MyState(MyStateID.NotStarted, dataClass); MyState s = new MyState(sParent, MyStateID.WaitingForUserInput, dataClass); MyState s2 = new MyState(sParent, MyStateID.Active, dataClass); Console.WriteLine("SuperState sParent name:{0}", sParent.FullName); Console.WriteLine("State s name:{0}", s.FullName); Console.WriteLine("State s2 name:{0}", s2.FullName); s.RegisterOnEventTransition(new SpEnumToInt(MyEventType.Stop), new SpStateTransition(SpStateTransitionType.NextState, s2, null)); ISpStateMachine sm = new MyStateMachine(dataClass, s); ISpEventStore store = new SimpleDequeEventStore(new MyTickMsg()); ISpBehaviorOnEvent behavior = new SpPeriodicWakeupOnly(); ISpPeriodicTimer timer = new WinSimpleTimer(new TimeSpan(0, 0, 0, 0, 1000)); ISpEventListner listner = new SimpleEventListner(); listner.ResponseReceived += new Action<ISpEventMessage>((msg) => { }); // TODO - Need a default response msg // Simulates DI SpStateMachineEngine engine = new SpStateMachineEngine(listner, store, behavior, sm, timer); engine.Start(); Thread.Sleep(3000); //sm.Tick(new BaseMsg(99, 456)); //listner.PostMessage(new SpBaseMsg(MyMessageType 777, 12345)); listner.PostMessage(new MyBaseMsg(MyMsgType.SimpleMsg, MyEventType.Stop)); Thread.Sleep(3000); engine.Stop(); Console.WriteLine("Disposing Engine - thread should not output while I wait 3 seconds"); engine.Dispose(); Thread.Sleep(3000); Console.WriteLine("Done"); // Multi call test engine.Dispose(); engine.Dispose(); engine.Dispose(); Console.WriteLine("Engine Disposed"); //SpState<DataClass> state = new SpState<DataClass>(dataClass); //SpStateMachine<DataClass> stateMachine = new SpStateMachine<DataClass>(dataClass, state); }); }
private void ProcessAndSendTcpResponse(MyState state, bool isSubSequentResponse) { if (state.Response == null) { state.Response = DnsMessageBase.CreateByFlag(state.Buffer, TsigKeySelector, null); state.Response.IsQuery = false; state.Response.AdditionalRecords.Clear(); state.Response.AuthorityRecords.Clear(); state.Response.ReturnCode = ReturnCode.ServerFailure; } byte[] newTsigMac; int length = state.Response.Encode(true, state.NextTsigMac, isSubSequentResponse, out state.Buffer, out newTsigMac); if (length > 65535) { if ((state.Response.Questions.Count == 0) || (state.Response.Questions[0].RecordType != RecordType.Axfr)) { OnExceptionThrown(new ArgumentException("The length of the serialized response is greater than 65,535 bytes")); state.Response = DnsMessageBase.CreateByFlag(state.Buffer, TsigKeySelector, null); state.Response.IsQuery = false; state.Response.ReturnCode = ReturnCode.ServerFailure; state.Response.AdditionalRecords.Clear(); state.Response.AuthorityRecords.Clear(); length = state.Response.Encode(true, state.NextTsigMac, isSubSequentResponse, out state.Buffer, out newTsigMac); } else { List<DnsRecordBase> nextPacketRecords = new List<DnsRecordBase>(); do { int lastIndex = Math.Min(500, state.Response.AnswerRecords.Count / 2); int removeCount = state.Response.AnswerRecords.Count - lastIndex; nextPacketRecords.InsertRange(0, state.Response.AnswerRecords.GetRange(lastIndex, removeCount)); state.Response.AnswerRecords.RemoveRange(lastIndex, removeCount); length = state.Response.Encode(true, state.NextTsigMac, isSubSequentResponse, out state.Buffer, out newTsigMac); } while (length > 65535); state.Response.AnswerRecords = nextPacketRecords; } } else { state.Response = null; } state.NextTsigMac = newTsigMac; state.Timer = new Timer(TcpTimedOut, state, state.TimeRemaining, System.Threading.Timeout.Infinite); state.AsyncResult = state.Stream.BeginWrite(state.Buffer, 0, length, EndTcpSendData, state); }
public MessageReader(UInt32 dataSetGuid) { State = new MyState(); m_DataSetGuid = dataSetGuid; }
private void EndTcpAcceptConnection(IAsyncResult ar) { TcpClient client = null; NetworkStream stream = null; try { client = _tcpListener.EndAcceptTcpClient(ar); stream = client.GetStream(); MyState state = new MyState() { Client = client, Stream = stream, Buffer = new byte[2] }; state.Timer = new Timer(TcpTimedOut, state, Timeout, System.Threading.Timeout.Infinite); state.AsyncResult = stream.BeginRead(state.Buffer, 0, 2, EndTcpReadLength, state); } catch (ObjectDisposedException) { return; } catch (Exception e) { try { if (stream != null) { stream.Close(); } } catch {} try { if (client != null) { client.Close(); } } catch {} OnExceptionThrown(e); } StartTcpAcceptConnection(); }
public void SetPreState(MyState state) { this.m_cPreState = state; }
public MyCommand(MyState state) { _state = state; }
private void EndTcpAcceptConnection(IAsyncResult ar) { TcpClient client = null; NetworkStream stream = null; try { client = _tcpListener.EndAcceptTcpClient(ar); lock (_tcpListener) { _hasActiveTcpListener = false; StartTcpAcceptConnection(); } stream = client.GetStream(); MyState state = new MyState { Client = client, Stream = stream, Buffer = new byte[2], BytesToReceive = 2, TimeRemaining = Timeout }; state.Timer = new Timer(TcpTimedOut, state, state.TimeRemaining, System.Threading.Timeout.Infinite); state.AsyncResult = stream.BeginRead(state.Buffer, 0, 2, EndTcpReadLength, state); } catch (Exception e) { HandleTcpException(e, stream, client); } }
public void SetGlobalState(MyState state) { this.m_cGlobalState = state; }
protected bool Equals(MyState other) { return string.Equals(this.Name, other.Name); }
public void SetCurrentState(MyState state) { this.m_cCurrentState = state; }