Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 소켓 명세 변경사항 반영 #174

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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