mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
Reverse argument order for sendTo
It makes more sense to put the address first then have the large structure to send as the second argument to sendTo. The opposite order was originally chosen to be similar to that of sendto in BSD sockets.
This commit is contained in:
1 parent
183d2921a8
commit
295cc7543a
24 files changed
+87
-74
No files matched your search
@@ -52,8 +52,8 @@ export default function CreateSaveModal(props) {
|
||||
|
||||
setCreatingSave(true);
|
||||
control.sendTo(
|
||||
{ instanceId: props.instance.id },
|
||||
new libData.InstanceCreateSaveRequest(name, seed, mapGenSettings, mapSettings),
|
||||
{ instanceId: props.instance.id }
|
||||
).then(() => {
|
||||
form.resetFields();
|
||||
setVisible(false);
|
||||
|
||||
@@ -23,8 +23,8 @@ export default function InstanceRcon(props) {
|
||||
setRunning(true);
|
||||
try {
|
||||
let result = await control.sendTo(
|
||||
{ instanceId: props.id },
|
||||
new libData.InstanceSendRconRequest(command),
|
||||
{ instanceId: props.id }
|
||||
);
|
||||
setOutput(result);
|
||||
} finally {
|
||||
|
||||
@@ -132,7 +132,8 @@ export default function InstanceViewPage(props) {
|
||||
if (key === "export") {
|
||||
setExportingData(true);
|
||||
control.sendTo(
|
||||
new libData.InstanceExportDataRequest(), { instanceId }
|
||||
{ instanceId },
|
||||
new libData.InstanceExportDataRequest(),
|
||||
).catch(
|
||||
notifyErrorHandler("Error exporting data")
|
||||
).finally(() => {
|
||||
@@ -141,12 +142,14 @@ export default function InstanceViewPage(props) {
|
||||
|
||||
} else if (key === "extract") {
|
||||
control.sendTo(
|
||||
new libData.InstanceExtractPlayersRequest(), { instanceId }
|
||||
{ instanceId },
|
||||
new libData.InstanceExtractPlayersRequest(),
|
||||
).catch(notifyErrorHandler("Error extracting player data"));
|
||||
|
||||
} else if (key === "kill") {
|
||||
control.sendTo(
|
||||
new libData.InstanceKillRequest(), { instanceId }
|
||||
{ instanceId },
|
||||
new libData.InstanceKillRequest(),
|
||||
).catch(notifyErrorHandler("Error killing instance"));
|
||||
|
||||
} else if (key === "delete") {
|
||||
|
||||
@@ -84,7 +84,8 @@ export default function InstancesPage() {
|
||||
&& <Button onClick={e => instanceList.forEach(instance => {
|
||||
if (["starting", "running"].includes(instance.status)) {
|
||||
control.sendTo(
|
||||
new libData.InstanceStopRequest(), { instanceId: instance.id }
|
||||
{ instanceId: instance.id },
|
||||
new libData.InstanceStopRequest(),
|
||||
).catch(notifyErrorHandler("Error stopping instance"));
|
||||
}
|
||||
})
|
||||
|
||||
@@ -52,8 +52,8 @@ export default function LoadScenarioModal(props) {
|
||||
|
||||
setLoadingScenario(true);
|
||||
control.sendTo(
|
||||
{ instanceId: props.instance.id },
|
||||
new libData.InstanceLoadScenarioRequest(scenario, seed, mapGenSettings, mapSettings),
|
||||
{ instanceId: props.instance.id }
|
||||
).then(() => {
|
||||
setVisible(false);
|
||||
}).catch(
|
||||
|
||||
@@ -228,7 +228,8 @@ export default function SavesList(props) {
|
||||
onClick={() => {
|
||||
setStarting(true);
|
||||
control.sendTo(
|
||||
new libData.InstanceStartRequest(save.name), { instanceId: props.instance.id }
|
||||
{ instanceId: props.instance.id },
|
||||
new libData.InstanceStartRequest(save.name),
|
||||
).catch(
|
||||
notifyErrorHandler("Error loading save")
|
||||
).finally(
|
||||
|
||||
@@ -17,14 +17,16 @@ export default function StartStopInstanceButton(props) {
|
||||
let action;
|
||||
if (props.instance["status"] === "stopped") {
|
||||
action = control.sendTo(
|
||||
new libData.InstanceStartRequest(undefined), { instanceId: props.instance["id"] }
|
||||
{ instanceId: props.instance["id"] },
|
||||
new libData.InstanceStartRequest(undefined),
|
||||
).catch(
|
||||
notifyErrorHandler("Error starting instance")
|
||||
);
|
||||
|
||||
} else if (["starting", "running"].includes(props.instance["status"])) {
|
||||
action = control.sendTo(
|
||||
new libData.InstanceStopRequest(), { instanceId: props.instance["id"] }
|
||||
{ instanceId: props.instance["id"] },
|
||||
new libData.InstanceStopRequest(),
|
||||
).catch(
|
||||
notifyErrorHandler("Error stopping instance")
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ export function useSaves(instanceId) {
|
||||
let [saves, setSaves] = useState([]);
|
||||
|
||||
function updateSaves() {
|
||||
control.sendTo(new libData.InstanceListSavesRequest(), { instanceId }).then(updatedSaves => {
|
||||
control.sendTo({ instanceId }, new libData.InstanceListSavesRequest()).then(updatedSaves => {
|
||||
setSaves(updatedSaves);
|
||||
}).catch(err => {
|
||||
logger.error(`Failed to list instance saves: ${err}`);
|
||||
|
||||
Reference in new issue
Block a user