Hi,

I didn't get much from the examples of gRPC so I'm trying to build my own 
Java server and client. So far I have managed to build my own proto file 
and use protoc to create Java class from it. My proto file is like this:

syntax = "proto3";

option java_package = "testing";
option java_outer_classname = "TTTService";

package testing;

// The TTT service definition.
service Game {
  // Sends status of game
    rpc SayStatus (Placexor) returns (GameStatus) {}
}
message Placexor {
    int32 row = 1; // row
    int32 column = 2; // column
    int32 gameid = 3; // games id
}
message GameStatus {
    string iswin = 1; 
    string isturn = 2;
    int32 gameid = 3;
    int32 success = 4; 
}



It is a server for TicTacToe game so I'm trying to have client to send the 
row, column, and gamenumbers and server will answer whether it has been 
succesfully done and if it is players turn etc. I'm currently stuck and 
cannot figure out how to proceed. I tried to copy code from 
HelloWorldServer and alter it to get better understanding. My server code 
looks currently like this:

public class Server {
    private int port = 1234;
    private io.grpc.Server server;
    /**
     * @param args
     * @throws IOException 
     * @throws InterruptedException 
     */
    public static void main(String[] args) throws IOException, 
InterruptedException {
        final Server server = new Server();
        server.start();

    }
    private void start() throws IOException {
        //server = ServerBuilder.forPort(port).addService(new 
Listener()).build().start();
        server = ServerBuilder.forPort(port).addService(new TTTService()).
build().start();
        System.err.println("Server started and listening in port: "+port);
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                // Use stderr here since the logger may have been reset by 
its JVM shutdown hook.
                System.err.println("*** shutting down gRPC server since JVM 
is shutting down");
                Server.this.stop();
                System.err.println("*** server shut down");
            }
        });
    }

Which results in null pointer. Have I totally misunderstood everything and 
how should I continue from this?

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/f58ac98f-be7f-48a0-89da-39a12ef7a02d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to