playing around with protobufs
parent
3786234d20
commit
498789cdce
|
@ -1,6 +1,7 @@
|
|||
.gradle
|
||||
.idea
|
||||
build
|
||||
out
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
|
20
build.gradle
20
build.gradle
|
@ -54,12 +54,22 @@ dependencies {
|
|||
/*==== You probably don't have to edit below this line =======*/
|
||||
|
||||
protobuf {
|
||||
// Configure the protoc executable
|
||||
protoc {
|
||||
// Configure the protoc executable
|
||||
protoc {
|
||||
// Download from repositories
|
||||
//artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3'
|
||||
artifact = 'com.google.protobuf:protoc:3.+'
|
||||
}
|
||||
artifact = 'com.google.protobuf:protoc:3.+'
|
||||
}
|
||||
}
|
||||
|
||||
idea {
|
||||
module {
|
||||
// add protobuf generated sources to generated source dir.
|
||||
sourceDirs += file(protobuf.generatedFilesBaseDir)
|
||||
generatedSourceDirs += file(protobuf.generatedFilesBaseDir)
|
||||
|
||||
// Don't exclude build directory
|
||||
excludeDirs -= file(buildDir)
|
||||
}
|
||||
}
|
||||
|
||||
// Used to generate initial maven-dir layout
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
import com.google.protobuf.ByteString;
|
||||
import meerkat.bulletinboard.BulletinBoard;
|
||||
import meerkat.comm.BulletinBoardMessageProtos;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static meerkat.comm.BulletinBoardMessageProtos.*;
|
||||
|
||||
/**
|
||||
* Created by talm on 10/26/15.
|
||||
*/
|
||||
public class Demo {
|
||||
static void main(String args[]) {
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Nothing to see yet");
|
||||
|
||||
BulletinBoardMessage msg;
|
||||
|
||||
BulletinBoardMessage.Unsigned msgContents = BulletinBoardMessage.Unsigned.newBuilder()
|
||||
.addTags("test")
|
||||
.setData(ByteString.copyFromUtf8("some data"))
|
||||
.build();
|
||||
|
||||
msg = BulletinBoardMessage.newBuilder()
|
||||
.setMsg(msgContents)
|
||||
.build();
|
||||
|
||||
try {
|
||||
msg.writeTo(System.err);
|
||||
} catch (IOException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package meerkat.comm;
|
||||
|
||||
message BulleinBoardMessage {
|
||||
repeated int32 tags = 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meerkat.comm;
|
||||
|
||||
import 'meerkat/crypto/signature.proto';
|
||||
|
||||
option java_outer_classname = "BulletinBoardMessageProtos";
|
||||
|
||||
message BulletinBoardMessage {
|
||||
message Unsigned {
|
||||
// Optional tags describing message
|
||||
repeated string tags = 1;
|
||||
|
||||
// The actual content of the message
|
||||
bytes data = 2;
|
||||
}
|
||||
|
||||
Unsigned msg = 1;
|
||||
|
||||
// Signature of message (and tags)
|
||||
meerkat.crypto.Signature sig = 2;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package meerkat.crypto;
|
||||
|
||||
option java_outer_classname = "SignatureProtos";
|
||||
|
||||
message Signature {
|
||||
enum Type {
|
||||
ECDSA = 0;
|
||||
DSA = 1;
|
||||
}
|
||||
Type type = 1;
|
||||
|
||||
bytes data = 2;
|
||||
}
|
Loading…
Reference in New Issue