mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-23 05:14:54 +01:00
fix: added proto docs, changed a little bit
This commit is contained in:
parent
0b0c5c1904
commit
4764e47da5
3 changed files with 46 additions and 6 deletions
|
@ -2,34 +2,59 @@ syntax = "proto3";
|
|||
|
||||
package codemp.buffer;
|
||||
|
||||
// handle buffer changes, keep in sync users
|
||||
service Buffer {
|
||||
// attach to a buffer and receive operations
|
||||
rpc Attach (BufferPayload) returns (stream RawOp);
|
||||
// send an operation for a specific buffer
|
||||
rpc Edit (OperationRequest) returns (BufferEditResponse);
|
||||
// create a new buffer
|
||||
rpc Create (BufferPayload) returns (BufferCreateResponse);
|
||||
// get contents of buffer
|
||||
rpc Sync (BufferPayload) returns (BufferResponse);
|
||||
}
|
||||
|
||||
// empty request
|
||||
message BufferCreateResponse {}
|
||||
|
||||
// empty request
|
||||
message BufferEditResponse {}
|
||||
|
||||
// raw wire operation sequence event
|
||||
message RawOp {
|
||||
// operation seq serialized to json
|
||||
string opseq = 1;
|
||||
|
||||
// user id that has executed the operation
|
||||
string user = 2;
|
||||
}
|
||||
|
||||
// client buffer operation request
|
||||
message OperationRequest {
|
||||
// buffer path to operate onto
|
||||
string path = 1;
|
||||
|
||||
// buffer hash of source state
|
||||
string hash = 2;
|
||||
string opseq = 3;
|
||||
string user = 4;
|
||||
|
||||
// raw operation sequence
|
||||
RawOp op = 3;
|
||||
}
|
||||
|
||||
// generic buffer operation request
|
||||
message BufferPayload {
|
||||
// buffer path to operate onto
|
||||
string path = 1;
|
||||
|
||||
// user id that is requesting the operation
|
||||
string user = 2;
|
||||
|
||||
// optional buffer full content for replacing
|
||||
optional string content = 3;
|
||||
}
|
||||
|
||||
// response from server with buffer content
|
||||
message BufferResponse {
|
||||
string content = 2;
|
||||
// current buffer content
|
||||
string content = 1;
|
||||
}
|
||||
|
|
|
@ -2,29 +2,43 @@ syntax = "proto3";
|
|||
|
||||
package codemp.cursor;
|
||||
|
||||
// handle cursor events and broadcast to all users
|
||||
service Cursor {
|
||||
// send cursor movement to server
|
||||
rpc Moved (CursorEvent) returns (MovedResponse);
|
||||
// attach to a workspace and receive cursor events
|
||||
rpc Listen (UserIdentity) returns (stream CursorEvent);
|
||||
}
|
||||
|
||||
// empty request
|
||||
message MovedResponse {}
|
||||
|
||||
// a tuple indicating row and column
|
||||
message RowCol {
|
||||
int32 row = 1;
|
||||
int32 col = 2;
|
||||
}
|
||||
|
||||
// cursor position object
|
||||
message CursorPosition {
|
||||
// path of current buffer this cursor is into
|
||||
string buffer = 1;
|
||||
// cursor start position
|
||||
RowCol start = 2;
|
||||
// cursor end position
|
||||
RowCol end = 3;
|
||||
}
|
||||
|
||||
// cursor event, with user id and cursor position
|
||||
message CursorEvent {
|
||||
// user moving the cursor
|
||||
string user = 1;
|
||||
// new cursor position
|
||||
CursorPosition position = 2;
|
||||
}
|
||||
|
||||
// payload identifying user for cursor attaching
|
||||
message UserIdentity {
|
||||
// user identifier
|
||||
string id = 1;
|
||||
}
|
||||
|
|
|
@ -114,9 +114,10 @@ async fn send_opseq(tx: &mut BufferClient<Channel>, uid: String, path: String, o
|
|||
}
|
||||
};
|
||||
let req = OperationRequest {
|
||||
hash: "".into(),
|
||||
user: uid,
|
||||
opseq, path,
|
||||
path, hash: "".into(),
|
||||
op: Some(RawOp {
|
||||
opseq, user: uid,
|
||||
}),
|
||||
};
|
||||
match tx.edit(req).await {
|
||||
Ok(_) => true,
|
||||
|
|
Loading…
Reference in a new issue