/// <summary> /// Initializes the DeploymentContext to connect with SpatialOS given a hostname and port. /// </summary> /// <param name="workerType">Type of worker</param> /// <param name="workerId">ID of worker</param> /// <param name="hostname">Hostname to connect</param> /// <param name="port">Port to connect</param> public void Init(string workerType, string workerId, string hostname, ushort port) { if (_status != Status.Uninitialized) { _logger.Warn("Attempt to reinitialize DeploymentContext has been cancelled."); return; } _workerType = workerType; var connection = CreateConnection(hostname, port, workerId); var dispatcher = CreateDispatcher(connection); if (connection == null || !connection.IsConnected) { throw new ContextInitializationFailedException("Failed to connect to SpatialOS"); } _wrappedConnection = new ConnectionWrapper(connection); _wrappedDispatcher = new DispatcherWrapper(dispatcher); Logger.DefaultLogger.AttachConnection(_wrappedConnection); _status = Status.Initialized; }
public static void Exit(Connection conn, int status) { Logger.Warn("Exiting: " + status); }