private void Dispose(bool disposing) { if (disposing) { CloseWebSocket(); uri = null; if (!callbackManager.IsNull()) { callbackManager.Dispose(); callbackManager = null; } if (!sendingQueue.IsNull()) { sendingQueue.Clear(); sendingQueue = null; } pinging = false; connectionOpenEvent.Reset(); connectionOpenEvent.Close(); if (!receivedQueue.IsNull()) { receivedQueue.Clear(); receivedQueue = null; } } }
private static void Entities_OnCloseAll() { MyAPIGateway.Entities.OnCloseAll -= Entities_OnCloseAll; DoTests = null; Path = null; Timer = null; s_logger = null; }
private SocketMgr() { m_Handlers = new Dictionary <short, MessageEventHandler>(512); m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_RecvBuffer = new byte[ByteArray.MSG_MAX_LEN]; m_RecvLength = 0; m_BytesPool = new ObjPool <ByteArray>(32); m_MessageQueue = new LockedQueue <ByteArray>(32); m_SendBuffer = new ByteArray(128); }
public HttpProxyClientDataAdapter(FullHttpProxyServer server, ProxyNetworkService service, Logger logger) { _server = server; _service = service; _cancellationSource = new CancellationTokenSource(); _conns = new LockedQueue <ProxyConnection>(-1, _cancellationSource.Token); _logger = logger; _graphs = new List <NetGraph>(); Description = "HTTP Proxy Server"; }
public Connection(string url, bool sendFromThread) { uri = new Uri(url); callbackManager = new CallbackControl(); receivedQueue = new LockedQueue <Response>(); if (sendFromThread) { new Thread(ThreadDequeuSendMessages).Start(sendingQueue = new LockedQueue <Request>()); } new Thread(ThreadPing).Start(pinging = true); }
public ConsoleControl() { InitializeComponent(); _tokenSource = new CancellationTokenSource(); _input = new LockedQueue <string>(-1, _tokenSource.Token); _error = new ConsoleTextWriter(this, true); _output = new ConsoleTextWriter(this, false); _console = new ConsoleImpl(this, _input); _history = new List <string>(); this.Disposed += ConsoleControl_Disposed; _consoleThread = new Thread(consoleThread_DoWork); }
public ConsoleControl() { InitializeComponent(); _tokenSource = new CancellationTokenSource(); _input = new LockedQueue<string>(-1, _tokenSource.Token); _error = new ConsoleTextWriter(this, true); _output = new ConsoleTextWriter(this, false); _console = new ConsoleImpl(this, _input); _history = new List<string>(); this.Disposed += ConsoleControl_Disposed; _consoleThread = new Thread(consoleThread_DoWork); }
/// <summary> /// Default constructor /// </summary> protected BaseDecoupledPipelineNode() { _cancel_source = new CancellationTokenSource(); _input = new LockedQueue <DataFrame>(-1, _cancel_source.Token); _lockObject = new object(); }
public HttpProxyClientDataAdapter(FullHttpProxyServer server, ProxyNetworkService service, Logger logger) { _server = server; _service = service; _cancellationSource = new CancellationTokenSource(); _conns = new LockedQueue<ProxyConnection>(-1, _cancellationSource.Token); _logger = logger; _graphs = new List<NetGraph>(); Description = "HTTP Proxy Server"; }
/// <summary> /// Default constructor /// </summary> public PipelineStream() { _dataQueue = new LockedQueue<byte[]>(); _readTimeout = Timeout.Infinite; }
/// <summary> /// Test a path between current position and destination. /// </summary> private void TestPath(Vector3D destination, MyEntity ignoreEntity, byte runId, bool isAlternate, bool tryAlternates, bool slowDown = false) { m_logger.debugLog("m_navBlock == null", Logger.severity.FATAL, condition: m_navBlock == null); if (runId != m_runId) { m_logger.debugLog("destination changed, abort", Logger.severity.DEBUG); return; } if (!lock_testPath.TryAcquireExclusive()) { m_logger.debugLog("Already running, requeue (destination:" + destination + ", ignoreEntity: " + ignoreEntity.getBestName() + ", runId :" + runId + ", isAlternate: " + isAlternate + ", tryAlternates: " + tryAlternates + ", slowDown: " + slowDown + ")"); LockedQueue <Action> queue = isAlternate ? m_pathLow : m_pathHigh; queue.Enqueue(() => TestPath(destination, ignoreEntity, runId, isAlternate, tryAlternates)); return; } try { if (m_grid != m_navBlock.Grid) { m_logger.debugLog("Grid has changed, from " + m_grid.getBestName() + " to " + m_navBlock.Grid.getBestName() + ", nav block: " + m_navBlock.Block.getBestName(), Logger.severity.WARNING); return; } m_logger.debugLog("Running, (destination:" + destination + ", ignoreEntity: " + ignoreEntity.getBestName() + ", runId :" + runId + ", isAlternate: " + isAlternate + ", tryAlternates: " + tryAlternates + ", slowDown: " + slowDown + ")"); MyEntity obstructing; Vector3? pointOfObstruction; if (!isAlternate && !m_ignoreAsteroid) { if (slowDown) { if ((m_planetCheckSpeed.CurrentState & PlanetChecker.State.Blocked) != 0) { float speed = Vector3.Distance(m_planetCheckSpeed.ObstructionPoint, m_navBlock.WorldPosition) * 0.1f; if (speed < 1f) { speed = 1f; } m_navSet.Settings_Task_NavWay.SpeedTarget = speed; m_logger.debugLog("Path blocked by planet, set SpeedTarget to " + speed + ", obstructed by planet", Logger.severity.TRACE); return; } } else { if ((m_planetCheckDest.CurrentState & PlanetChecker.State.Blocked) != 0 && // planet checker is using an older displacement so verify that obstruction is closer than destination Vector3D.DistanceSquared(m_navBlock.WorldPosition, m_planetCheckDest.ObstructionPoint) < Vector3D.DistanceSquared(m_navBlock.WorldPosition, destination)) { m_logger.debugLog("path blocked by planet, to destination: " + (destination - m_navBlock.WorldPosition) + ", to obstruction: " + (m_planetCheckDest.ObstructionPoint - m_navBlock.WorldPosition)); if (m_pathState < PathState.Searching) { m_pathState = PathState.Searching; } obstructing = m_planetCheckDest.gravcomp; Vector3 direction = Vector3.Normalize(m_navBlock.WorldPosition - obstructing.GetCentre()); pointOfObstruction = m_planetCheckDest.ObstructionPoint + direction * 1e3f; float distance = Vector3.Distance(m_navBlock.WorldPosition, pointOfObstruction.Value); MoveObstruction = obstructing; m_pathHigh.Clear(); ClearAltPath(); if ((m_planetCheckDest.CurrentState & PlanetChecker.State.BlockedPath) != 0) { FindAlternate_AroundObstruction(pointOfObstruction.Value - m_navBlock.WorldPosition, new Vector3[] { direction }, 1e4f, runId); } else // blocked by gravity { FindAlternate_AroundObstruction(pointOfObstruction.Value - m_navBlock.WorldPosition, new Vector3[] { direction }, 1e6f, runId); } m_pathLow.Enqueue(() => { if (m_altPath_AlternatesFound != 0) { SetWaypoint(); } RunItem(); }); m_pathLow.Enqueue(() => m_pathState = PathState.Path_Blocked); return; } } } // for alternates, check that it can be better than current value if (isAlternate) { float distToWaypointSquared = (float)Vector3D.DistanceSquared(m_navBlock.WorldPosition, destination); if (distToWaypointSquared * WaypointDistanceBias * WaypointDistanceBias > m_altPath_PathValue * m_altPath_PathValue) { m_logger.debugLog("no point in checking alternate path, bias is too high", Logger.severity.TRACE); m_logger.debugLog("no alternate, yet path value is set", Logger.severity.ERROR, condition: m_altPath_AlternatesFound == 0); IncrementAlternatesFound(); return; } } if (m_pathChecker.TestFast(m_navBlock, destination, m_ignoreAsteroid, ignoreEntity, m_landing)) { m_logger.debugLog("path is clear (fast)", Logger.severity.TRACE); PathClear(ref destination, runId, isAlternate, slowDown); return; } if (m_pathChecker.TestSlow(out obstructing, out pointOfObstruction)) { m_logger.debugLog("path is clear (slow)", Logger.severity.TRACE); PathClear(ref destination, runId, isAlternate, slowDown); return; } if (runId != m_runId) { m_logger.debugLog("destination changed, abort", Logger.severity.DEBUG); return; } if (slowDown) { float speed = Vector3.Distance(pointOfObstruction.Value, m_navBlock.WorldPosition) * 0.1f; if (speed < 1f) { speed = 1f; } IMyEntity destEntity = m_navSet.Settings_Current.DestinationEntity; if (destEntity != null) { destEntity = destEntity.GetTopMostParent(); } if (obstructing.GetTopMostParent() == destEntity) { m_navSet.Settings_Task_NavWay.SpeedMaxRelative = speed; m_logger.debugLog("Set SpeedMaxRelative to " + speed + ", obstructing: " + obstructing.getBestName() + ", DestinationEntity: " + m_navSet.Settings_Current.DestinationEntity.getBestName(), Logger.severity.TRACE); } else { m_navSet.Settings_Task_NavWay.SpeedTarget = speed; m_logger.debugLog("Set SpeedTarget to " + speed + ", obstructing: " + obstructing.getBestName() + ", DestinationEntity: " + m_navSet.Settings_Current.DestinationEntity.getBestName(), Logger.severity.TRACE); } return; } if (m_pathState < PathState.Searching) { m_pathState = PathState.Searching; } m_logger.debugLog("path is blocked by " + obstructing.getBestName() + " at " + pointOfObstruction + ", ignoreEntity: " + ignoreEntity.getBestName(), isAlternate ? Logger.severity.TRACE : Logger.severity.DEBUG); m_logger.debugLog("grid: " + obstructing.GetTopMostParent().DisplayName, isAlternate ? Logger.severity.TRACE : Logger.severity.DEBUG, condition: obstructing is IMyCubeBlock); if (isAlternate && m_altPath_AlternatesFound != 0) { IncrementAlternatesFound(); } if (tryAlternates) { //float angle = m_navSet.Settings_Current.DistanceAngle; //if (angle > 0.1f && CanRotate) //{ // m_logger.debugLog("wait for rotation", "TestPath()"); // return; //} if (m_navSet.Settings_Task_NavEngage.NavigatorMover != m_navSet.Settings_Current.NavigatorMover) { m_logger.debugLog("obstructed while flying to a waypoint, throwing it out and starting over", Logger.severity.DEBUG); m_navSet.OnTaskComplete_NavWay(); return; } ClearAltPath(); MoveObstruction = obstructing; TryAlternates(runId, pointOfObstruction.Value, obstructing); } } finally { lock_testPath.ReleaseExclusive(); RunItem(); } }
private void Awake() { _instance = this; operationQueue = new LockedQueue <OperationBean>(); }
public LayerSectionDataAdapter(LayerSectionNode outputNode) { _inputQueue = new LockedQueue <DataFrame>(); _readTimeout = Timeout.Infinite; _outputNode = outputNode; }
protected override void UnloadData() { base.UnloadData(); if (MyAPIGateway.Entities != null) MyAPIGateway.Entities.OnEntityAdd -= Entities_OnEntityAdd; ManagerStatus = Status.Terminated; UpdateRegistrar = null; AllBlockScriptConstructors = null; EveryBlockScriptConstructors = null; CharacterScriptConstructors = null; PlayerScriptConstructors = null; GridScriptConstructors = null; PlayerLeaves = null; AnyPlayerLeaves = null; playersAPI = null; playersCached = null; AddRemoveActions = null; CubeBlocks = null; Characters = null; Instance = null; Profiler.Write(); }
public void Init() { //myLogger.debugLog("entered Init", "Init()"); try { if (MyAPIGateway.CubeBuilder == null || MyAPIGateway.Entities == null || MyAPIGateway.Multiplayer == null || MyAPIGateway.Parallel == null || MyAPIGateway.Players == null || MyAPIGateway.Session == null || MyAPIGateway.TerminalActionsHelper == null || MyAPIGateway.Utilities == null) return; if (!MyAPIGateway.Multiplayer.IsServer && MyAPIGateway.Session.Player == null) { if (!player_wait_message) { player_wait_message = true; myLogger.alwaysLog("Waiting for player value", "Init()"); } return; } myLogger.alwaysLog("Got player value", "Init()"); UpdateRegistrar = new Dictionary<uint, List<Action>>(); AllBlockScriptConstructors = new Dictionary<MyObjectBuilderType, List<Action<IMyCubeBlock>>>(); EveryBlockScriptConstructors = new List<Action<IMyCubeBlock>>(); CharacterScriptConstructors = new List<Action<IMyCharacter>>(); PlayerScriptConstructors = new List<Action<IMyPlayer>>(); GridScriptConstructors = new List<Action<IMyCubeGrid>>(); PlayerLeaves = new Dictionary<IMyPlayer, Action>(); AnyPlayerLeaves = new List<Action<IMyPlayer>>(); playersAPI = new List<IMyPlayer>(); playersCached = new List<IMyPlayer>(); AddRemoveActions = new LockedQueue<Action>(8); if (!MyAPIGateway.Multiplayer.MultiplayerActive) { myLogger.debugLog("Single player, running server scripts", "Init()", Logger.severity.INFO); RegisterScripts_Server(); } else if (MyAPIGateway.Multiplayer.IsServer) { myLogger.debugLog("This is the server, running server scripts", "Init()", Logger.severity.INFO); RegisterScripts_Server(); } else { myLogger.debugLog("Client, running client scripts only", "Init()", Logger.severity.INFO); } ManagerStatus = Status.Initialized; } catch (Exception ex) { myLogger.alwaysLog("Failed to Init(): " + ex, "Init()", Logger.severity.FATAL); ManagerStatus = Status.Terminated; } }
// Use this for initialization private void Awake() { operationQueue = new LockedQueue <LogOpBean>(); _instance = this; }
internal ConsoleImpl(ConsoleControl control, LockedQueue <string> input) { _control = control; _input = input; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">The generator to use</param> /// <param name="token">A cancellation token</param> public GeneratorDataAdapter(IDataGenerator generator, CancellationToken token) { _generator = generator; _inputQueue = new LockedQueue<DataFrame>(-1, token); }
/// <summary> /// Constructor /// </summary> /// <param name="generator">The generator to use</param> /// <param name="token">A cancellation token</param> public GeneratorDataAdapter(IDataGenerator generator, CancellationToken token) { _generator = generator; _inputQueue = new LockedQueue <DataFrame>(-1, token); }
/// <summary> /// Default constructor /// </summary> protected BaseDecoupledPipelineNode() { _input = new LockedQueue <DataFrame>(); _lockObject = new object(); }
public LayerSectionDataAdapter(LayerSectionNode outputNode) { _inputQueue = new LockedQueue<DataFrame>(); _readTimeout = Timeout.Infinite; _outputNode = outputNode; }
public Cluster(int num) { Max = num; Slaves = new LockedQueue<IMyEntity>(num); }
private void Awake() { _instance = this; operationQueue = new LockedQueue <OperationBean>(); SetStates(VirtualManState.Init); }
/// <summary> /// Constructor /// </summary> public QueuedDataAdapter(CancellationToken token) { _inputQueue = new LockedQueue <DataFrame>(-1, token); _outputQueue = new LockedQueue <DataFrame>(-1, token); _readTimeout = Timeout.Infinite; }
internal ConsoleImpl(ConsoleControl control, LockedQueue<string> input) { _control = control; _input = input; }
public void Init() { //myLogger.debugLog("entered Init", "Init()"); try { if (MyAPIGateway.CubeBuilder == null || MyAPIGateway.Entities == null || MyAPIGateway.Multiplayer == null || MyAPIGateway.Parallel == null || MyAPIGateway.Players == null || MyAPIGateway.Session == null || MyAPIGateway.TerminalActionsHelper == null || MyAPIGateway.Utilities == null) return; if (!MyAPIGateway.Multiplayer.IsServer && MyAPIGateway.Session.Player == null) return; myLogger.alwaysLog("World: " + MyAPIGateway.Session.Name + ", Path: " + MyAPIGateway.Session.CurrentPath, Logger.severity.INFO); Saver.Instance.Initialize(); UpdateRegistrar = new Dictionary<uint, List<Action>>(); AllBlockScriptConstructors = new Dictionary<MyObjectBuilderType, List<Action<IMyCubeBlock>>>(); EveryBlockScriptConstructors = new List<Action<IMyCubeBlock>>(); CharacterScriptConstructors = new List<Action<IMyCharacter>>(); PlayerScriptConstructors = new List<Action<IMyPlayer>>(); GridScriptConstructors = new List<Action<IMyCubeGrid>>(); PlayerLeaves = new Dictionary<IMyPlayer, Action>(); AnyPlayerLeaves = new List<Action<IMyPlayer>>(); playersAPI = new List<IMyPlayer>(); playersCached = new List<IMyPlayer>(); AddRemoveActions = new LockedQueue<Action>(8); ExternalRegistrations = new LockedQueue<Action>(1); if (!MyAPIGateway.Multiplayer.MultiplayerActive) { myLogger.alwaysLog("Single player, running server scripts", Logger.severity.INFO); RegisterScripts_Server(); } else if (MyAPIGateway.Multiplayer.IsServer) { myLogger.alwaysLog("This is the server, running server scripts", Logger.severity.INFO); RegisterScripts_Server(); } else { myLogger.alwaysLog("Client, running client scripts only", Logger.severity.INFO); } Logger.debugNotify("ARMS dev version loaded", 10000); ManagerStatus = Status.Initialized; } catch (Exception ex) { myLogger.alwaysLog("Failed to Init(): " + ex, Logger.severity.FATAL); ManagerStatus = Status.Terminated; } }
/// <summary> /// Default constructor /// </summary> protected BaseDecoupledPipelineNode() { _input = new LockedQueue<DataFrame>(); _lockObject = new object(); }
private static void Entities_OnCloseAll() { MyAPIGateway.Entities.OnCloseAll -= Entities_OnCloseAll; DoTests = null; Path = null; Timer = null; s_logger = null; }
/// <summary> /// Constructor /// </summary> public QueuedDataAdapter(CancellationToken token) { _inputQueue = new LockedQueue<DataFrame>(-1, token); _outputQueue = new LockedQueue<DataFrame>(-1, token); _readTimeout = Timeout.Infinite; }