@zaisma/game-server 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/node.js +5 -4
  2. package/package.json +1 -1
package/bin/node.js CHANGED
@@ -178,18 +178,19 @@ export function startServer(options) {
178
178
  // for its own databases. Answers 204 when that and onWebhook finished, so Zaisma counts it delivered;
179
179
  // anything else is tried again later.
180
180
  function answerWebhook(request, response) {
181
- const reply = (httpStatus, message) => {
182
- response.writeHead(httpStatus, { "Content-Type": "text/plain", "Cache-Control": "no-store" });
181
+ const reply = (httpStatus, message, isClosing = false) => {
182
+ response.writeHead(httpStatus, { "Content-Type": "text/plain", "Cache-Control": "no-store", ...(isClosing ? { Connection: "close" } : {}) });
183
183
  response.end(message);
184
184
  };
185
185
  if (request.method !== "POST") return reply(405, "Webhooks are POSTed.");
186
186
  if (!webhookSigningSecret) return reply(503, "Set ZAISMA_WEBHOOK_SIGNING_SECRET to the webhook's signing_secret to take its events.");
187
187
  const header = (name) => (typeof request.headers[name] === "string" ? request.headers[name] : null);
188
188
  const headers = { webhookId: header("webhook-id"), webhookTimestamp: header("webhook-timestamp"), webhookSignature: header("webhook-signature") };
189
- // A POST with no headers, or an old timestamp, is turned away before its body is read.
189
+ // A POST with no headers, or an old timestamp, is turned away before its body is read. Its connection
190
+ // closes, and says so, so the sender doesn't send its next request down a connection that's gone.
190
191
  const refuse = (httpStatus, error) => {
191
192
  response.once("finish", () => request.destroy());
192
- reply(httpStatus, `${error.message} ${error.fix}`);
193
+ reply(httpStatus, `${error.message} ${error.fix}`, true);
193
194
  };
194
195
  const chunks = [];
195
196
  let sizeBytes = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaisma/game-server",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Run your Zaisma game server: the same rooms on Zaisma or on your own server.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://zaisma.com",