chromatic/common/events.ts

22 lines
600 B
TypeScript

import { t } from "elysia";
interface ServerToClientEvents {
"server version": (semver: string) => void;
info: (message: string) => void;
"set cursor position": (user: string, pos: { x: number; y: number }) => void;
chat: (user: string, message: string) => void;
}
export const clientToServerEvents = t.Object({
message: t.Union([
t.Object({
type: t.Literal("set cursor position"),
x: t.Number(),
y: t.Number()
}),
t.Object({
type: t.Literal("chat"),
messageq: t.String()
})
])
});