[WIP] added dummy chat recieve for games on pong service
This commit is contained in:
parent
a81a870d74
commit
6894c30f92
2 changed files with 195 additions and 39 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { FastifyPluginAsync } from 'fastify';
|
||||
import { Static, Type } from 'typebox';
|
||||
import { broadcastNextGame} from '../broadcastNextGame';
|
||||
|
||||
export const ChatReq = Type.Object({
|
||||
message: Type.String(),
|
||||
|
|
@ -7,46 +8,42 @@ export const ChatReq = Type.Object({
|
|||
|
||||
export type ChatReq = Static<typeof ChatReq>;
|
||||
|
||||
const route: FastifyPluginAsync = async (fastify): Promise<void> => {
|
||||
fastify.post<{ Body: ChatReq }>(
|
||||
'/api/chat/broadcast',
|
||||
{
|
||||
schema: {
|
||||
body: ChatReq,
|
||||
hide: true,
|
||||
},
|
||||
config: { requireAuth: false },
|
||||
},
|
||||
async function(req, res) {
|
||||
// broadcast(this, { command: '', destination: '', user: 'CMwaLeSever!!', text: req.body.message, SenderWindowID: 'server' });
|
||||
void res;
|
||||
},
|
||||
);
|
||||
};
|
||||
export default route;
|
||||
|
||||
// const route: FastifyPluginAsync = async (fastify): Promise<void> => {
|
||||
// fastify.post('/api/chat/broadcast', {
|
||||
// schema: {
|
||||
// body: {
|
||||
// type: 'object',
|
||||
// required: ['nextGame'],
|
||||
// properties: {
|
||||
// nextGame: { type: 'string' }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }, async (req, reply) => {
|
||||
|
||||
// // Body only contains nextGame now
|
||||
// const gameLink: Promise<string> = Promise.resolve(req.body as string );
|
||||
|
||||
// // Broadcast nextGame
|
||||
// if (gameLink)
|
||||
// broadcastNextGame(fastify, gameLink);
|
||||
|
||||
// return reply.send({ status: 'ok' });
|
||||
// });
|
||||
// fastify.post<{ Body: ChatReq }>(
|
||||
// '/api/chat/broadcast',
|
||||
// {
|
||||
// schema: {
|
||||
// body: ChatReq,
|
||||
// hide: true,
|
||||
// },
|
||||
// config: { requireAuth: false },
|
||||
// },
|
||||
// async function(req, res) {
|
||||
// // broadcast(this, { command: '', destination: '', user: 'CMwaLeSever!!', text: req.body.message, SenderWindowID: 'server' });
|
||||
// void res;
|
||||
// },
|
||||
// );
|
||||
// };
|
||||
// export default route;
|
||||
|
||||
const route: FastifyPluginAsync = async (fastify): Promise<void> => {
|
||||
fastify.post('/api/chat/broadcast', {
|
||||
schema: {
|
||||
body: {
|
||||
type: 'object',
|
||||
required: ['nextGame'],
|
||||
properties: {
|
||||
nextGame: { type: 'string' }
|
||||
}
|
||||
}
|
||||
}
|
||||
}, async (req, reply) => {
|
||||
const gameLink: Promise<string> = Promise.resolve(req.body as string );
|
||||
if (gameLink)
|
||||
broadcastNextGame(fastify, gameLink);
|
||||
|
||||
return reply.send({ status: 'ok' });
|
||||
});
|
||||
};
|
||||
export default route;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue