hapticlink / server /src /socket /routes /test_connection.ts
avallef's picture
Changed addRoute method to be easier to understand
9dffdbf
import { z } from "zod";
import { Context, Route } from "../hapticLinkServer";
export interface TestConnectionPayload { }
export const TestConnnectionSchema = z.object({})
export function TestConnectionHandler(ctx: Context<TestConnectionPayload>) {
if (ctx.user) {
return ctx.ws.send(JSON.stringify({
"message": "test_connection_response",
"authenticated": true,
"username": ctx.user.username
}))
}
return ctx.ws.send(JSON.stringify({
"message": "test_connection_response",
"authenticated": false,
}))
}