Skip to content

Commit

Permalink
Feat: 소켓 명세 변경사항 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
LeHiHo committed Jan 16, 2024
1 parent da682a6 commit f2938e7
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 47 deletions.
107 changes: 63 additions & 44 deletions src/@types/socket.types.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,3 @@
interface pubInfo {
startDate: string;
endDate: string;
numberOfPeople: number;
tripName: string;
tripStatus: 'BEFORE' | 'DURING' | 'AFTER';
area: string;
subarea: string;
budget: number;
}

interface pubAddTripItem {
visitDate: string;
newTripItems: {
tourItemId: number;
}[];
}

interface pubUpdateTripItem {
visitDate: string;
tripItemOrder: {
tripItemId: number;
seqNum: number;
}[];
}

interface pubVisitDate {
// visitDate: '2024-01-07',
visitDate: string;
}

interface pubUpdatePrice {
price: number;
}

interface pubUpdateTransportation {
transportation: 'CAR' | 'PUBLIC_TRANSPORTATION';
}

interface pubMember {
memberId: number;
}

type subInfoMessage = (message: {
status: number;
message: string;
Expand Down Expand Up @@ -84,13 +41,15 @@ type subPathMessage = (response: {
tripId: number;
visitDate: string;
paths: {
fromTripItemId: number;
toTripItemId: number;
fromSeqNum: number;
toSeqNum: number;
fromLongitude: string;
fromLatitude: string;
toLongitude: string;
toLatitude: string;
transportation: string;
transportation: 'CAR' | 'PUBLIC_TRANSPORTATION';
pathInfo: {
price: number;
totalDistance: number;
Expand Down Expand Up @@ -128,3 +87,63 @@ type subBudgetMessage = (response: {
calculatedPrice: number;
};
}) => void;

interface pubInfo {
startDate: string;
endDate: string;
numberOfPeople: number;
tripName: string;
area: string;
subarea: string;
budget: number;
}

interface pubAddTripItem {
visitDate: string;
newTripItems: {
tourItemId: number;
}[];
}

interface pubUpdatePrice {
tripId: number;
visitDate: string;
price: number;
}

interface pubUpdateTripItem {
visitDate: string;
tripItemOrder: {
tripItemId: number;
seqNum: number;
}[];
}

interface pubUpdateTransportation {
tripId: number;
visitDate: string;
transportation: 'CAR' | 'PUBLIC_TRANSPORTATION';
}

interface pubVisitDate {
tripId: number;
oldVisitDate: string;
newVisitDate: string;
}

interface pubDeleteItem {
tripId: number;
visitDate: string;
}

interface pubMember {
memberId: number;
}

interface pubGetPathAndItems {
visitDate: string;
}

interface pubUpdateBudget {
budget: number;
}
26 changes: 24 additions & 2 deletions src/api/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ export const pubUpdateVisitDate = (
};

// 여행 아이템 삭제 이벤트 발생시
export const pubDeleteItem = (tripItemId: number) => {
export const pubDeleteItem = (
pubDeleteItem: pubDeleteItem,
tripItemId: number,
) => {
socketClient.publish({
destination: `/pub/tripItems/${tripItemId}/deleteItem`,
body: JSON.stringify(pubDeleteItem),
});
};

Expand Down Expand Up @@ -156,11 +160,29 @@ export const pubEnterMember = (pubMember: pubMember, tripId: string) => {

// 날짜별 여행 아이템 & 경로 조회
export const pubGetPathAndItems = (
pubGetPathAndItems: pubVisitDate,
pubGetPathAndItems: pubGetPathAndItems,
tripId: string,
) => {
socketClient.publish({
destination: `/pub/trips/${tripId}/getPathAndItems`,
body: JSON.stringify(pubGetPathAndItems),
});
};

// 접속중인 멤버 정보 조회
export const pubGetConnectedMember = (tripId: string) => {
socketClient.publish({
destination: `/pub/trips/${tripId}/getConnectedMember`,
});
};

// 목표 경비(예산) 변경시
export const pubUpdateBudget = (
pubUpdateBudget: pubUpdateBudget,
tripId: string,
) => {
socketClient.publish({
destination: `/pub/trips/${tripId}/updateBudget`,
body: JSON.stringify(pubUpdateBudget),
});
};
2 changes: 1 addition & 1 deletion src/recoil/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const tripIdState = atom<string | null>({

export const visitDateState = atom<{ visitDate: string } | null>({
key: 'visitDateState',
default: { visitDate: '2024-01-03' },
default: { visitDate: '2024-01-05' },
});

export const memberIdState = atom<{ memberId: number } | null>({
Expand Down

0 comments on commit f2938e7

Please sign in to comment.