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

DrawingDto-for-drawing-websocket-endpoint #41

Merged
merged 1 commit into from
Jul 22, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.swiftgathering_server.controller;

import com.example.swiftgathering_server.dto.DrawingDto;
import com.example.swiftgathering_server.dto.LocationDto;
import lombok.RequiredArgsConstructor;
import org.springframework.messaging.handler.annotation.MessageMapping;
Expand All @@ -16,4 +17,9 @@ public class WebSocketController {
public void location(LocationDto locationDto) {
simpMessageSendingOperations.convertAndSend("/topic/" + locationDto.getChannelId(), locationDto);
}

@MessageMapping("/drawing")
public void drawing(DrawingDto drawingDto) {
simpMessageSendingOperations.convertAndSend("/topic/" + drawingDto.getChannelId(), drawingDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public class GatheringSession {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private final UUID sessionId = UUID.randomUUID();
@Column(nullable = false, unique = true)
private UUID sessionId;

private LocalDateTime createdTime;

@ElementCollection
Expand All @@ -31,6 +33,7 @@ public class GatheringSession {

@Builder
public GatheringSession(List<GatheringSessionMember> gatheringSessionMembers, LocalDateTime createdTime) {
this.sessionId = UUID.randomUUID();
this.gatheringSessionMembers = gatheringSessionMembers;
this.createdTime = createdTime;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.example.swiftgathering_server.dto;

import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@NoArgsConstructor
public class DrawingDto {
private Long senderId;
private String channelId;
public StrokeState state;
public StrokePath path;

public DrawingDto(StrokeState state, StrokePath path) {
this.state = state;
this.path = path;
}

@Getter
@NoArgsConstructor
public static class StrokeState {
public String color;
public float width;
public float alpha;
public String blendMode;

public StrokeState(String color, float width, float alpha, String blendMode) {
this.color = color;
this.width = width;
this.alpha = alpha;
this.blendMode = blendMode;
}
}

@Getter
@NoArgsConstructor
public static class StrokePath {
public List<Coordinate> coordinates;

public StrokePath(List<Coordinate> coordinates) {
this.coordinates = coordinates;
}
}

@Getter
@NoArgsConstructor
public static class Coordinate {
public double latitude;
public double longitude;

public Coordinate(double latitude, double longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
}
}

This file was deleted.

Loading