public static WrappedOp <DisconnectOp> CreateDisconnectOp(string reason) { var op = new DisconnectOp { Reason = reason }; return(new WrappedOp <DisconnectOp>(op)); }
private void OnDisconnect(DisconnectOp op) { WorldCommands.DeallocateWorldCommandRequesters(EntityManager, worker.WorkerEntity); EntityManager.AddSharedComponentData(worker.WorkerEntity, new OnDisconnected { ReasonForDisconnect = op.Reason }); }
internal static void SignalApplicationQuit() { if (!ConnectionWasSuccessful) { receivedDisconnectOp = new DisconnectOp { Reason = "An application quit signal was received." }; } }
/// <summary> /// Call this to cleanly disconnect from SpatialOS. All entities that exist will be despawned. /// </summary> /// <remarks> /// It is invalid to call this method if Connect has not been called. /// </remarks> public static void Disconnect() { if (connectionLifecycle == null) { throw new InvalidOperationException("Disconnect called while not connected."); } receivedDisconnectOp = new DisconnectOp { Reason = "Disconnect was called by the user." }; Disconnecting = true; }
/// <summary> /// Starts a new background thread that will keep the connection to SpatialOS alive. /// We do not use the connection to the simulated player deployment, /// but we must ensure it is kept open to prevent the coordinator worker /// from being killed. /// </summary> private static void KeepConnectionAlive(Connection connection, Logger logger) { var thread = new Thread(() => { var isConnected = true; while (isConnected) { using (OpList opList = connection.GetOpList(GetOpListTimeoutInMilliseconds)) { var OpCount = opList.GetOpCount(); for (var i = 0; i < OpCount; ++i) { switch (opList.GetOpType(i)) { case OpType.Disconnect: { DisconnectOp op = opList.GetDisconnectOp(i); logger.WriteError("[disconnect] " + op.Reason, logToConnectionIfExists: false); isConnected = false; } break; default: break; } } } } }); // Don't keep thread / connection alive when main process stops. thread.IsBackground = true; thread.Start(); }
private void HandleDisconnect(DisconnectOp op) { disconnectCallbacks.InvokeAll(op); }
internal static void Disconnected(DisconnectOp disconnectOp) { receivedDisconnectOp = disconnectOp; Disconnecting = true; }
private void OnDisconnect(DisconnectOp op) { view.Disconnect(op.Reason); }