Skip to content

Commit

Permalink
added Protobuf definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed May 7, 2024
1 parent 49a3844 commit ec92f45
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 5 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageVersion Include="Akka.Persistence.Sql.Hosting" Version="1.5.13" />
<PackageVersion Include="Akka.Streams" Version="1.5.20" />
<PackageVersion Include="Akka.Streams.TestKit" Version="1.5.20" />
<PackageVersion Include="Grpc.Tools" Version="2.63.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageVersion Include="MudBlazor" Version="6.19.1" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/DrawTogether.Actors/DrawTogether.Actors.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<ItemGroup>
<PackageReference Include="Akka.Cluster.Hosting" />
<PackageReference Include="Akka.Streams" />
<PackageReference Include="Grpc.Tools">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
98 changes: 98 additions & 0 deletions src/DrawTogether.Actors/Serialization/Proto/DrawingProtocol.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
syntax = "proto3";

package DrawTogether.Actors.Serialization.Proto;

import "google/protobuf/timestamp.proto";

/* Primitives */
message UserId {
string id = 1;
}

message DrawingSessionId {
string id = 1;
}

message StrokeId {
int32 id = 1;
}

message Point {
double x = 1;
double y = 2;
}

message ConnectedStroke {
StrokeId id = 1;
repeated Point points = 2;
int32 strokeWidth = 3;
string strokeColor = 4;
}

/* Commands and events */
message AddUser {
DrawingSessionId drawingSessionId = 1;
UserId userId = 2;
}

message RemoveUser {
DrawingSessionId drawingSessionId = 1;
UserId userId = 2;

}

message AddStroke {
DrawingSessionId drawingSessionId = 2;
ConnectedStroke connectedStroke = 3;
}

message RemoveStroke {
DrawingSessionId drawingSessionId = 1;
StrokeId strokeId = 2;
}

message ClearStrokes {
DrawingSessionId drawingSessionId = 1;
}

message SessionClosed {
DrawingSessionId drawingSessionId = 1;
}

/* State */

message DrawingSessionState{
DrawingSessionId drawingSessionId = 1;
repeated ConnectedStroke connectedStrokes = 2;
repeated UserId connectedUsers = 3;
google.protobuf.Timestamp lastUpdated = 4;
}

/* Queries */

message GetDrawingSessionState {
DrawingSessionId drawingSessionId = 1;
}

message SubscribeToDrawingSessionState {
DrawingSessionId drawingSessionId = 1;
}

message SubscribeAcknowledged {
DrawingSessionId drawingSessionId = 1;
}

message UnsuscribeFromDrawingSessionState {
DrawingSessionId drawingSessionId = 1;
}

message UnsuscribeAcknowledged {
DrawingSessionId drawingSessionId = 1;
}

message DrawingActivityUpdated {
DrawingSessionId drawingSessionId = 1;
google.protobuf.Timestamp lastUpdated = 2;
int32 activeUsers = 3;
bool isRemoved = 4;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ public interface IDrawingSessionEvent : IWithDrawingSessionId { }

public static class DrawingSessionEvents
{
public sealed record DrawingSessionCreated(DrawingSessionId DrawingSessionId) : IDrawingSessionEvent;

public sealed record StrokeAdded(DrawingSessionId DrawingSessionId, ConnectedStroke Stroke) : IDrawingSessionEvent;

public sealed record StrokeRemoved(DrawingSessionId DrawingSessionId, StrokeId StrokeId) : IDrawingSessionEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using DrawTogether.Entities.Users;

namespace DrawTogether.Entities.Drawings.Messages;
namespace DrawTogether.Entities.Drawings.Messages;

/// <summary>
/// Marker interface for messages that have a <see cref="DrawingSessionId"/>.
Expand Down

0 comments on commit ec92f45

Please sign in to comment.