diff --git a/src/main/java/researcher/Client.java b/src/main/java/researcher/Client.java new file mode 100644 index 0000000000000000000000000000000000000000..7d2e5f0b0189cdfb4799c6b85ad10e74c90cb7eb --- /dev/null +++ b/src/main/java/researcher/Client.java @@ -0,0 +1,30 @@ +package researcher; + +import it.ewlab.researcher.ResearcherOuterClass.Researcher; + +import java.io.IOException; +import java.net.Socket; + +public class Client { + + public static void main(String[] args) throws IOException { + + Socket s = new Socket("localhost", 9999); + + Researcher r = + Researcher.newBuilder() + .setName("Gabriele") + .setSurname("Civitarese") + .setType(Researcher.ResearcherType.POSTDOC) + .addPaper(Researcher.Paper.newBuilder().setTitle("Activity Recognition") + .setYear(2014)) + .addPaper(Researcher.Paper.newBuilder().setTitle("Activity Recognition Again") + .setYear(2015)).build(); + + r.writeTo(s.getOutputStream()); + + s.close(); + + + } +} diff --git a/src/main/java/researcher/Server.java b/src/main/java/researcher/Server.java new file mode 100644 index 0000000000000000000000000000000000000000..da6ce56916691b1e9108ecce92a0b17314f7ec35 --- /dev/null +++ b/src/main/java/researcher/Server.java @@ -0,0 +1,24 @@ +package researcher; + +import it.ewlab.researcher.ResearcherOuterClass; + +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; + +public class Server { + + public static void main(String[] args) throws IOException { + + + ServerSocket serverSocket = new ServerSocket(9999); + + Socket s = serverSocket.accept(); + + ResearcherOuterClass.Researcher r = ResearcherOuterClass.Researcher.parseFrom(s.getInputStream()); + + System.out.println(r); + } + + +} diff --git a/src/main/proto/Researcher.proto b/src/main/proto/Researcher.proto new file mode 100644 index 0000000000000000000000000000000000000000..dd37f2576a2c1a3ed177354d7132ae87ff545df8 --- /dev/null +++ b/src/main/proto/Researcher.proto @@ -0,0 +1,21 @@ +package it.ewlab.researcher; + +message Researcher { + required string name = 1; + required string surname = 2; + + enum ResearcherType { + PHDSTUDENT = 0; + POSTDOC = 1; + ASSISTANTPROFESSOR = 2; + } + + message Paper { + required string title = 1; + required int32 year = 2; + + } + + repeated Paper paper = 3; + optional ResearcherType type = 4; +} \ No newline at end of file