move types to serverCalls.tsx
This commit is contained in:
parent
5f5e9fb716
commit
5f27739e7c
|
@ -1,4 +1,4 @@
|
|||
import {makeApiUrl, Scores, useMyWebSocket} from './serverCalls';
|
||||
import {makeApiUrl, PlayerInfoMessage, useMyWebSocket} from './serverCalls';
|
||||
import Column from './components/Column.tsx';
|
||||
import {ReadyState} from 'react-use-websocket';
|
||||
import {useEffect, useState} from 'react';
|
||||
|
@ -21,21 +21,6 @@ function ScoreRow({name, value}: {
|
|||
</tr>;
|
||||
}
|
||||
|
||||
type TankInfo = {
|
||||
readonly magazine: string;
|
||||
readonly position: { x: number; y: number };
|
||||
readonly orientation: number;
|
||||
readonly moving: boolean;
|
||||
}
|
||||
|
||||
type PlayerInfoMessage = {
|
||||
readonly name: string;
|
||||
readonly scores: Scores;
|
||||
readonly controls: string;
|
||||
readonly tank?: TankInfo;
|
||||
readonly openConnections: number;
|
||||
}
|
||||
|
||||
export default function PlayerInfo({player}: { player: string }) {
|
||||
const [shouldSendMessage, setShouldSendMessage] = useState(false);
|
||||
|
||||
|
|
|
@ -19,6 +19,21 @@ export type Player = {
|
|||
readonly scores: Scores;
|
||||
};
|
||||
|
||||
type TankInfo = {
|
||||
readonly magazine: string;
|
||||
readonly position: { x: number; y: number };
|
||||
readonly orientation: number;
|
||||
readonly moving: boolean;
|
||||
}
|
||||
|
||||
export type PlayerInfoMessage = {
|
||||
readonly name: string;
|
||||
readonly scores: Scores;
|
||||
readonly controls: string;
|
||||
readonly tank?: TankInfo;
|
||||
readonly openConnections: number;
|
||||
}
|
||||
|
||||
export function useMyWebSocket<T = unknown>(url: string, options: Options = {}) {
|
||||
return useWebSocket<T>(url, {
|
||||
shouldReconnect: () => true,
|
||||
|
|
Loading…
Reference in a new issue