Skip to content

Commit

Permalink
[n/a] Websocket Site Id (#911)
Browse files Browse the repository at this point in the history
- Adds siteId to /details response
- Appends siteId to url for websocket connection
  • Loading branch information
nick-telsan authored Apr 17, 2024
1 parent 30a7e25 commit c2c9bcf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const auctionSchema = z.object({
socketUrl: z.string(),
accountUrl: z.string(),
bidUrl: z.string(),
siteId: z.number(),
startTime: z.string(),
endTime: z.string(),
totalBids: z.number(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@ export function Socket({ auctionId }: SocketProps) {
}

function SocketHandler({ auctionId }: SocketProps) {
const { socketUrl, setSocketError, setSocketAuction, auctionStatus } =
useBiddingState();
const {
siteId,
socketUrl,
setSocketError,
setSocketAuction,
auctionStatus,
} = useBiddingState();

const { lastJsonMessage } = useWebSocket<SocketMessage>(
`${
process.env.NODE_ENV === 'development'
? socketUrlOverride
: socketUrl
}/${auctionId}`,
}/${siteId}-${auctionId}`,
{
onError: () => {
setSocketError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const useBiddingStore = create<BiddingState & BiddingActions>((set) => ({
socketUrl: '',
accountUrl: '',
bidUrl: '',
siteId: 1,

auctionStatus: 'initializing',
timeRemainingMs: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type UrlsType = {
socketUrl: string;
accountUrl: string;
bidUrl: string;
siteId: number;
};

export type TimingType = {
Expand Down

0 comments on commit c2c9bcf

Please sign in to comment.