chromatic/common/events.ts

23 lines
600 B
TypeScript
Raw Normal View History

2024-02-12 12:15:50 +00:00
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()
})
])
});