Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

Commit

Permalink
Broadcasting messages (#26)
Browse files Browse the repository at this point in the history
* broadcasting schema

* schema updates. next to fix tests

* now, we have all the tests translated. \n Now, to write the C++ protobuf translation thing.

* fix a lot of things (but more things left to do)

* tests pass!

* trunk fmt

* remove comment

Co-authored-by: Sualeh Asif <[email protected]>
  • Loading branch information
arvid220u and Sualeh Asif authored Jul 14, 2022
1 parent 7a3daa3 commit b02a19c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 32 deletions.
10 changes: 5 additions & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ build --incompatible_enable_cc_toolchain_resolution
try-import %workspace%/.user.bazelrc

# setting up remote caching
#build --bes_results_url=https://app.buildbuddy.io/invocation/
#build --bes_backend=grpcs://remote.buildbuddy.io
#build --remote_cache=grpcs://remote.buildbuddy.io
#build --remote_upload_local_results
#build --remote_timeout=3600
build --bes_results_url=https://app.buildbuddy.io/invocation/
build --bes_backend=grpcs://remote.buildbuddy.io
build --remote_cache=grpcs://remote.buildbuddy.io
# build --remote_upload_local_results
build --remote_timeout=3600
# build --experimental_remote_cache_compression
# build --experimental_remote_cache_async
# build --remote_download_toplevel
Expand Down
3 changes: 2 additions & 1 deletion asphr/asphr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ using absl::Time;

using std::unordered_map;
using std::unordered_set;
} // namespace asphr
} // namespace asphr

#define CEIL_DIV(a, b) (((a) + (b)-1) / (b))

// MESSAGE_SIZE is the size of the message in bytes
// this refers to the size of a CHUNK, not a complete message
constexpr size_t MESSAGE_SIZE = 1024;
constexpr size_t MESSAGE_SIZE_BITS = MESSAGE_SIZE * 8;

Expand Down
50 changes: 30 additions & 20 deletions schema/daemon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ message GetMyPublicIDRequest {}

message GetMyPublicIDResponse {
string public_id = 1;
string story =
2; // en encoding of the public identifier in a nice story format
string story = 2;
// en encoding of the public identifier in a nice story format
}

message AddSyncFriendRequest {
Expand Down Expand Up @@ -168,38 +168,48 @@ message RemoveFriendRequest { string unique_name = 1; }
message RemoveFriendResponse {}

message SendMessageRequest {
string unique_name = 1;
repeated string unique_name = 1;
string message = 2;
}

message SendMessageResponse {}

message BaseMessage {
// this ID is NOT the same as the ID in message.proto
// in particular, this ID is guaranteed to be unique among ALL messages (on a
// given device), whereas the ID in message.proto is only unique for each
// <sender, recipient> pair. the format of this ID is something like
// (to|from):sender:sequence_number
int32 id = 1;
string message = 2;
string unique_name = 3;
string display_name = 4;
message IncomingMaybeFriend {
string public_id = 1;

optional string unique_name = 2;
optional string display_name = 3;
}

message IncomingMessage {
BaseMessage m = 1;
google.protobuf.Timestamp delivered_at = 2;
bool seen = 3;
bool delivered = 4;
int32 uid = 1;
string message = 2;

string from_unique_name = 3;
string from_display_name = 4;

repeated IncomingMaybeFriend other_recipients = 5;

google.protobuf.Timestamp delivered_at = 6;
bool seen = 7;
bool delivered = 8;
}

message OutgoingMessage {
BaseMessage m = 1;
google.protobuf.Timestamp sent_at = 2;
message OutgoingFriend {
string unique_name = 1;
string display_name = 2;
bool delivered = 3;
google.protobuf.Timestamp delivered_at = 4;
}

message OutgoingMessage {
int32 uid = 1;
string message = 2;

repeated OutgoingFriend to_friends = 3;
google.protobuf.Timestamp sent_at = 4;
}

message GetMessagesRequest {
enum Filter {
ALL = 0;
Expand Down
19 changes: 13 additions & 6 deletions schema/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ package asphrclient;
// keep this in sync with db.rs, SystemMessage
enum SystemMessage { OUTGOING_INVITATION = 0; }

// this message protobuf contains everything needed in
// a message. currently, messages only support a utf-8 message content
// as well as a list of cc-ed recipients. in the future, we may
// want to add pictures here, and more.
message Message {
repeated string other_recipients = 1;
string msg = 2;
}

// Given that we have a very very limited bandwidth, our goal is to define a
// Message type that is as small as possible.
//
Expand All @@ -25,19 +34,17 @@ enum SystemMessage { OUTGOING_INVITATION = 0; }
//
// IMPORTANT: update GUARANTEED_MESSAGE_SIZE in client_lib.hpp whenever this is
// updated.
message Message {
message Chunk {
// sequence_number is a unique id for the message. it is unique for a <sender,
// receiver> ordered pair. if the id is 0, then the message is a dummy
// message, with no actual msg to display to the user.
// TODO: to optimize space usage, we should merge the id here and the nonce
// used for encryption. this requires some careful thought with dummy
// messages.
uint32 sequence_number = 1;
// msg contains the actual UTF-8 message, if such a message exists
// In the future, we probably want this to be `bytes`, encoding a protobuf.
// The protobuf will contain a string message and possibly other information,
// like pictures or reply metadata.
string msg = 2;
// msg is a chunk of a byte sequence that alltogether form the serialization
// of a Message, defined above. this msg has a maximum length.
bytes msg = 2;
// if the message is a long message, this field contains the number of parts
// it has this field is not set if the message isn't long.
uint32 num_chunks = 3;
Expand Down

0 comments on commit b02a19c

Please sign in to comment.