Skip to content

Commit 2cb9487

Browse files
committed
Tweak message handler
1 parent 1be2292 commit 2cb9487

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

api/sockets/messageHandler.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ async function processRecord(record: SQSRecord) {
5252
return;
5353
}
5454

55-
// Only accept "chat" and "game"
56-
if (verb !== "chat" && verb !== "game") {
55+
if (!["chat", "game", "test"].includes(verb)) {
5756
console.warn("Unsupported verb:", verb);
5857
return;
5958
}
@@ -75,10 +74,10 @@ async function processRecord(record: SQSRecord) {
7574

7675
const now = Math.floor(Date.now() / 1000);
7776

78-
for (const item of result.Items ?? []) {
79-
console.log(`Processing item: ${JSON.stringify(item)}`);
80-
const connectionId = item.sk.S!;
81-
const ttl = item.ttl?.N ? parseInt(item.ttl.N) : null;
77+
for (const conn of result.Items ?? []) {
78+
console.log(`Processing connection: ${JSON.stringify(conn)}`);
79+
const connectionId = conn.sk.S!;
80+
const ttl = conn.ttl?.N ? parseInt(conn.ttl.N) : null;
8281

8382
// Delete expired TTL entries
8483
if (ttl && ttl < now) {

serverless.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ provider:
7373
stage: ${opt:stage, 'dev'}
7474
profile: ${self:custom.stageConfig.${self:provider.stage}.profile}
7575
region: us-east-1
76-
apiGateway:
77-
websocketApiName: myWebSocketApi
78-
websocketApi:
79-
subprotocols:
80-
- auth # <-- fixed subprotocol name the browser requests
8176
logs:
8277
websocket: true
8378
environment:

0 commit comments

Comments
 (0)