Spaces:
Runtime error
Runtime error
File size: 645 Bytes
61ffaad 9dffdbf 61ffaad 9dffdbf 61ffaad d32b1fb 61ffaad 9dffdbf 61ffaad d32b1fb 61ffaad | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import { z } from "zod";
import { Context, Route } from "../hapticLinkServer";
export interface SetUsernamePayload {
username: string;
}
export const SetUsernameSchema = z.object({
username: z.string(),
});
export function SetUsernameHandler(ctx: Context<SetUsernamePayload>) {
ctx.user.username = ctx.payload.username;
return ctx.ws.send(
JSON.stringify({
message: "set_username_response",
status: "success",
user: {
id: ctx.user.id,
username: ctx.user.username,
currentRoom: ctx.user.currentRoom,
},
})
);
}
|