1
0
Fork 0

Initial grpc generated code

pull/1/head
Ambrose Chua 2019-04-12 19:13:50 +08:00
parent 91cac82ba8
commit 2adcb4f516
3 changed files with 82 additions and 2 deletions

View File

@ -5,6 +5,15 @@ Turn the lights on!
## Developing
grpc-tools doesn't work on ARM, so developing on x86_64 GLIBC is required.
1. Get dependencies: `yarn install`
2. Start server: `yarn start`
To generate gRPC files again, run `yarn generate`
## Running
```
yarn install
yarn start
```

View File

@ -0,0 +1,68 @@
// GENERATED CODE -- DO NOT EDIT!
'use strict';
var grpc = require('grpc');
var framebuffer_pb = require('./framebuffer_pb.js');
function serialize_DrawResponse(arg) {
if (!(arg instanceof framebuffer_pb.DrawResponse)) {
throw new Error('Expected argument of type DrawResponse');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_DrawResponse(buffer_arg) {
return framebuffer_pb.DrawResponse.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_FrameBuffer(arg) {
if (!(arg instanceof framebuffer_pb.FrameBuffer)) {
throw new Error('Expected argument of type FrameBuffer');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_FrameBuffer(buffer_arg) {
return framebuffer_pb.FrameBuffer.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_FrameSequence(arg) {
if (!(arg instanceof framebuffer_pb.FrameSequence)) {
throw new Error('Expected argument of type FrameSequence');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_FrameSequence(buffer_arg) {
return framebuffer_pb.FrameSequence.deserializeBinary(new Uint8Array(buffer_arg));
}
var DrawerService = exports.DrawerService = {
// DrawFrame draws one frame
drawFrame: {
path: '/Drawer/DrawFrame',
requestStream: false,
responseStream: false,
requestType: framebuffer_pb.FrameBuffer,
responseType: framebuffer_pb.DrawResponse,
requestSerialize: serialize_FrameBuffer,
requestDeserialize: deserialize_FrameBuffer,
responseSerialize: serialize_DrawResponse,
responseDeserialize: deserialize_DrawResponse,
},
// DrawFrames draws a series of frames
drawFrames: {
path: '/Drawer/DrawFrames',
requestStream: false,
responseStream: false,
requestType: framebuffer_pb.FrameSequence,
responseType: framebuffer_pb.DrawResponse,
requestSerialize: serialize_FrameSequence,
requestDeserialize: deserialize_FrameSequence,
responseSerialize: serialize_DrawResponse,
responseDeserialize: deserialize_DrawResponse,
},
};
exports.DrawerClient = grpc.makeGenericClientConstructor(DrawerService);

View File

@ -7,9 +7,12 @@
"license": "MPL-2.0",
"scripts": {
"generate": "yarn run generate-grpc",
"generate-grpc": "protoc -I../../framebuffer ../../framebuffer/framebuffer.proto --js_out=import_style=commonjs,binary:framebuffer --grpc_out=framebuffer --plugin=protoc-gen-grpc=grpc_tools_node_protoc_plugin"
"generate-grpc": "grpc_tools_node_protoc -I../../framebuffer ../../framebuffer/framebuffer.proto --js_out=import_style=commonjs,binary:framebuffer --grpc_out=framebuffer --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin`"
},
"dependencies": {
"grpc": "^1.19.0"
},
"devDependencies": {
"grpc-tools": "^1.7.3"
}
}