Skip to content
This repository was archived by the owner on Dec 4, 2021. It is now read-only.

Commit 3554010

Browse files
authored
AddMessageToQueue and ClearMessageQueue (#47)
* Added AddMessageToQueue and ClearMessageQueue RPC and regenerated python files * Removed exe file and fixed client and server files * Fixed merge conflict Co-authored-by: Nanar Boursalian <nanar.boursalian01@gmail.com>
1 parent dca8502 commit 3554010

7 files changed

Lines changed: 246 additions & 304 deletions

File tree

client/ledsign/led_sign_client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function healthCheck(officerName, signIp) {
1717
grpc.credentials.createInsecure()
1818
);
1919
const healthCheckRequest = new messages.LedSignRequest();
20-
healthCheckRequest.setOfficerName(officerName);
20+
healthCheckRequest.setMessage(officerName);
2121
return new Promise(function(resolve, reject) {
2222
client.healthCheck(healthCheckRequest, function(err, response) {
2323
if (err || !response) {

client/ledsign/led_sign_grpc_pb.js

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,26 @@
44
var grpc = require('grpc');
55
var led_sign_pb = require('./led_sign_pb.js');
66

7-
function serialize_LedSignRecord(arg) {
8-
if (!(arg instanceof led_sign_pb.LedSignRecord)) {
9-
throw new Error('Expected argument of type LedSignRecord');
10-
}
11-
return Buffer.from(arg.serializeBinary());
12-
}
13-
14-
function deserialize_LedSignRecord(buffer_arg) {
15-
return led_sign_pb.LedSignRecord.deserializeBinary(new Uint8Array(buffer_arg));
16-
}
17-
18-
function serialize_LedSignRequest(arg) {
19-
if (!(arg instanceof led_sign_pb.LedSignRequest)) {
20-
throw new Error('Expected argument of type LedSignRequest');
7+
function serialize_LedSignMessage(arg) {
8+
if (!(arg instanceof led_sign_pb.LedSignMessage)) {
9+
throw new Error('Expected argument of type LedSignMessage');
2110
}
2211
return Buffer.from(arg.serializeBinary());
2312
}
2413

25-
function deserialize_LedSignRequest(buffer_arg) {
26-
return led_sign_pb.LedSignRequest.deserializeBinary(new Uint8Array(buffer_arg));
14+
function deserialize_LedSignMessage(buffer_arg) {
15+
return led_sign_pb.LedSignMessage.deserializeBinary(new Uint8Array(buffer_arg));
2716
}
2817

29-
function serialize_LedSignResponse(arg) {
30-
if (!(arg instanceof led_sign_pb.LedSignResponse)) {
31-
throw new Error('Expected argument of type LedSignResponse');
18+
function serialize_LedSignRecord(arg) {
19+
if (!(arg instanceof led_sign_pb.LedSignRecord)) {
20+
throw new Error('Expected argument of type LedSignRecord');
3221
}
3322
return Buffer.from(arg.serializeBinary());
3423
}
3524

36-
function deserialize_LedSignResponse(buffer_arg) {
37-
return led_sign_pb.LedSignResponse.deserializeBinary(new Uint8Array(buffer_arg));
25+
function deserialize_LedSignRecord(buffer_arg) {
26+
return led_sign_pb.LedSignRecord.deserializeBinary(new Uint8Array(buffer_arg));
3827
}
3928

4029

@@ -43,10 +32,10 @@ var LedSignService = exports.LedSignService = {
4332
path: '/LedSign/HealthCheck',
4433
requestStream: false,
4534
responseStream: false,
46-
requestType: led_sign_pb.LedSignRequest,
35+
requestType: led_sign_pb.LedSignMessage,
4736
responseType: led_sign_pb.LedSignRecord,
48-
requestSerialize: serialize_LedSignRequest,
49-
requestDeserialize: deserialize_LedSignRequest,
37+
requestSerialize: serialize_LedSignMessage,
38+
requestDeserialize: deserialize_LedSignMessage,
5039
responseSerialize: serialize_LedSignRecord,
5140
responseDeserialize: deserialize_LedSignRecord,
5241
},
@@ -55,11 +44,33 @@ var LedSignService = exports.LedSignService = {
5544
requestStream: false,
5645
responseStream: false,
5746
requestType: led_sign_pb.LedSignRecord,
58-
responseType: led_sign_pb.LedSignResponse,
47+
responseType: led_sign_pb.LedSignMessage,
5948
requestSerialize: serialize_LedSignRecord,
6049
requestDeserialize: deserialize_LedSignRecord,
61-
responseSerialize: serialize_LedSignResponse,
62-
responseDeserialize: deserialize_LedSignResponse,
50+
responseSerialize: serialize_LedSignMessage,
51+
responseDeserialize: deserialize_LedSignMessage,
52+
},
53+
addMessageToQueue: {
54+
path: '/LedSign/AddMessageToQueue',
55+
requestStream: false,
56+
responseStream: false,
57+
requestType: led_sign_pb.LedSignMessage,
58+
responseType: led_sign_pb.LedSignMessage,
59+
requestSerialize: serialize_LedSignMessage,
60+
requestDeserialize: deserialize_LedSignMessage,
61+
responseSerialize: serialize_LedSignMessage,
62+
responseDeserialize: deserialize_LedSignMessage,
63+
},
64+
clearMessageQueue: {
65+
path: '/LedSign/ClearMessageQueue',
66+
requestStream: false,
67+
responseStream: false,
68+
requestType: led_sign_pb.LedSignMessage,
69+
responseType: led_sign_pb.LedSignMessage,
70+
requestSerialize: serialize_LedSignMessage,
71+
requestDeserialize: deserialize_LedSignMessage,
72+
responseSerialize: serialize_LedSignMessage,
73+
responseDeserialize: deserialize_LedSignMessage,
6374
},
6475
};
6576

client/ledsign/led_sign_pb.js

Lines changed: 21 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ var jspb = require('google-protobuf');
1111
var goog = jspb;
1212
var global = Function('return this')();
1313

14+
goog.exportSymbol('proto.LedSignMessage', null, global);
1415
goog.exportSymbol('proto.LedSignRecord', null, global);
15-
goog.exportSymbol('proto.LedSignRequest', null, global);
16-
goog.exportSymbol('proto.LedSignResponse', null, global);
1716

1817
/**
1918
* Generated by JsPbCodeGenerator.
@@ -25,12 +24,12 @@ goog.exportSymbol('proto.LedSignResponse', null, global);
2524
* @extends {jspb.Message}
2625
* @constructor
2726
*/
28-
proto.LedSignRequest = function(opt_data) {
27+
proto.LedSignMessage = function(opt_data) {
2928
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
3029
};
31-
goog.inherits(proto.LedSignRequest, jspb.Message);
30+
goog.inherits(proto.LedSignMessage, jspb.Message);
3231
if (goog.DEBUG && !COMPILED) {
33-
proto.LedSignRequest.displayName = 'proto.LedSignRequest';
32+
proto.LedSignMessage.displayName = 'proto.LedSignMessage';
3433
}
3534

3635

@@ -45,8 +44,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) {
4544
* for transitional soy proto support: http://goto/soy-param-migration
4645
* @return {!Object}
4746
*/
48-
proto.LedSignRequest.prototype.toObject = function(opt_includeInstance) {
49-
return proto.LedSignRequest.toObject(opt_includeInstance, this);
47+
proto.LedSignMessage.prototype.toObject = function(opt_includeInstance) {
48+
return proto.LedSignMessage.toObject(opt_includeInstance, this);
5049
};
5150

5251

@@ -55,153 +54,11 @@ proto.LedSignRequest.prototype.toObject = function(opt_includeInstance) {
5554
* @param {boolean|undefined} includeInstance Whether to include the JSPB
5655
* instance for transitional soy proto support:
5756
* http://goto/soy-param-migration
58-
* @param {!proto.LedSignRequest} msg The msg instance to transform.
57+
* @param {!proto.LedSignMessage} msg The msg instance to transform.
5958
* @return {!Object}
6059
* @suppress {unusedLocalVariables} f is only used for nested messages
6160
*/
62-
proto.LedSignRequest.toObject = function(includeInstance, msg) {
63-
var f, obj = {
64-
officerName: jspb.Message.getFieldWithDefault(msg, 1, "")
65-
};
66-
67-
if (includeInstance) {
68-
obj.$jspbMessageInstance = msg;
69-
}
70-
return obj;
71-
};
72-
}
73-
74-
75-
/**
76-
* Deserializes binary data (in protobuf wire format).
77-
* @param {jspb.ByteSource} bytes The bytes to deserialize.
78-
* @return {!proto.LedSignRequest}
79-
*/
80-
proto.LedSignRequest.deserializeBinary = function(bytes) {
81-
var reader = new jspb.BinaryReader(bytes);
82-
var msg = new proto.LedSignRequest;
83-
return proto.LedSignRequest.deserializeBinaryFromReader(msg, reader);
84-
};
85-
86-
87-
/**
88-
* Deserializes binary data (in protobuf wire format) from the
89-
* given reader into the given message object.
90-
* @param {!proto.LedSignRequest} msg The message object to deserialize into.
91-
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
92-
* @return {!proto.LedSignRequest}
93-
*/
94-
proto.LedSignRequest.deserializeBinaryFromReader = function(msg, reader) {
95-
while (reader.nextField()) {
96-
if (reader.isEndGroup()) {
97-
break;
98-
}
99-
var field = reader.getFieldNumber();
100-
switch (field) {
101-
case 1:
102-
var value = /** @type {string} */ (reader.readString());
103-
msg.setOfficerName(value);
104-
break;
105-
default:
106-
reader.skipField();
107-
break;
108-
}
109-
}
110-
return msg;
111-
};
112-
113-
114-
/**
115-
* Serializes the message to binary data (in protobuf wire format).
116-
* @return {!Uint8Array}
117-
*/
118-
proto.LedSignRequest.prototype.serializeBinary = function() {
119-
var writer = new jspb.BinaryWriter();
120-
proto.LedSignRequest.serializeBinaryToWriter(this, writer);
121-
return writer.getResultBuffer();
122-
};
123-
124-
125-
/**
126-
* Serializes the given message to binary data (in protobuf wire
127-
* format), writing to the given BinaryWriter.
128-
* @param {!proto.LedSignRequest} message
129-
* @param {!jspb.BinaryWriter} writer
130-
* @suppress {unusedLocalVariables} f is only used for nested messages
131-
*/
132-
proto.LedSignRequest.serializeBinaryToWriter = function(message, writer) {
133-
var f = undefined;
134-
f = message.getOfficerName();
135-
if (f.length > 0) {
136-
writer.writeString(
137-
1,
138-
f
139-
);
140-
}
141-
};
142-
143-
144-
/**
145-
* optional string officer_name = 1;
146-
* @return {string}
147-
*/
148-
proto.LedSignRequest.prototype.getOfficerName = function() {
149-
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
150-
};
151-
152-
153-
/** @param {string} value */
154-
proto.LedSignRequest.prototype.setOfficerName = function(value) {
155-
jspb.Message.setProto3StringField(this, 1, value);
156-
};
157-
158-
159-
160-
/**
161-
* Generated by JsPbCodeGenerator.
162-
* @param {Array=} opt_data Optional initial data array, typically from a
163-
* server response, or constructed directly in Javascript. The array is used
164-
* in place and becomes part of the constructed object. It is not cloned.
165-
* If no data is provided, the constructed object will be empty, but still
166-
* valid.
167-
* @extends {jspb.Message}
168-
* @constructor
169-
*/
170-
proto.LedSignResponse = function(opt_data) {
171-
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
172-
};
173-
goog.inherits(proto.LedSignResponse, jspb.Message);
174-
if (goog.DEBUG && !COMPILED) {
175-
proto.LedSignResponse.displayName = 'proto.LedSignResponse';
176-
}
177-
178-
179-
if (jspb.Message.GENERATE_TO_OBJECT) {
180-
/**
181-
* Creates an object representation of this proto suitable for use in Soy templates.
182-
* Field names that are reserved in JavaScript and will be renamed to pb_name.
183-
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
184-
* For the list of reserved names please see:
185-
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
186-
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
187-
* for transitional soy proto support: http://goto/soy-param-migration
188-
* @return {!Object}
189-
*/
190-
proto.LedSignResponse.prototype.toObject = function(opt_includeInstance) {
191-
return proto.LedSignResponse.toObject(opt_includeInstance, this);
192-
};
193-
194-
195-
/**
196-
* Static version of the {@see toObject} method.
197-
* @param {boolean|undefined} includeInstance Whether to include the JSPB
198-
* instance for transitional soy proto support:
199-
* http://goto/soy-param-migration
200-
* @param {!proto.LedSignResponse} msg The msg instance to transform.
201-
* @return {!Object}
202-
* @suppress {unusedLocalVariables} f is only used for nested messages
203-
*/
204-
proto.LedSignResponse.toObject = function(includeInstance, msg) {
61+
proto.LedSignMessage.toObject = function(includeInstance, msg) {
20562
var f, obj = {
20663
message: jspb.Message.getFieldWithDefault(msg, 1, "")
20764
};
@@ -217,23 +74,23 @@ proto.LedSignResponse.toObject = function(includeInstance, msg) {
21774
/**
21875
* Deserializes binary data (in protobuf wire format).
21976
* @param {jspb.ByteSource} bytes The bytes to deserialize.
220-
* @return {!proto.LedSignResponse}
77+
* @return {!proto.LedSignMessage}
22178
*/
222-
proto.LedSignResponse.deserializeBinary = function(bytes) {
79+
proto.LedSignMessage.deserializeBinary = function(bytes) {
22380
var reader = new jspb.BinaryReader(bytes);
224-
var msg = new proto.LedSignResponse;
225-
return proto.LedSignResponse.deserializeBinaryFromReader(msg, reader);
81+
var msg = new proto.LedSignMessage;
82+
return proto.LedSignMessage.deserializeBinaryFromReader(msg, reader);
22683
};
22784

22885

22986
/**
23087
* Deserializes binary data (in protobuf wire format) from the
23188
* given reader into the given message object.
232-
* @param {!proto.LedSignResponse} msg The message object to deserialize into.
89+
* @param {!proto.LedSignMessage} msg The message object to deserialize into.
23390
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
234-
* @return {!proto.LedSignResponse}
91+
* @return {!proto.LedSignMessage}
23592
*/
236-
proto.LedSignResponse.deserializeBinaryFromReader = function(msg, reader) {
93+
proto.LedSignMessage.deserializeBinaryFromReader = function(msg, reader) {
23794
while (reader.nextField()) {
23895
if (reader.isEndGroup()) {
23996
break;
@@ -257,21 +114,21 @@ proto.LedSignResponse.deserializeBinaryFromReader = function(msg, reader) {
257114
* Serializes the message to binary data (in protobuf wire format).
258115
* @return {!Uint8Array}
259116
*/
260-
proto.LedSignResponse.prototype.serializeBinary = function() {
117+
proto.LedSignMessage.prototype.serializeBinary = function() {
261118
var writer = new jspb.BinaryWriter();
262-
proto.LedSignResponse.serializeBinaryToWriter(this, writer);
119+
proto.LedSignMessage.serializeBinaryToWriter(this, writer);
263120
return writer.getResultBuffer();
264121
};
265122

266123

267124
/**
268125
* Serializes the given message to binary data (in protobuf wire
269126
* format), writing to the given BinaryWriter.
270-
* @param {!proto.LedSignResponse} message
127+
* @param {!proto.LedSignMessage} message
271128
* @param {!jspb.BinaryWriter} writer
272129
* @suppress {unusedLocalVariables} f is only used for nested messages
273130
*/
274-
proto.LedSignResponse.serializeBinaryToWriter = function(message, writer) {
131+
proto.LedSignMessage.serializeBinaryToWriter = function(message, writer) {
275132
var f = undefined;
276133
f = message.getMessage();
277134
if (f.length > 0) {
@@ -287,13 +144,13 @@ proto.LedSignResponse.serializeBinaryToWriter = function(message, writer) {
287144
* optional string message = 1;
288145
* @return {string}
289146
*/
290-
proto.LedSignResponse.prototype.getMessage = function() {
147+
proto.LedSignMessage.prototype.getMessage = function() {
291148
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
292149
};
293150

294151

295152
/** @param {string} value */
296-
proto.LedSignResponse.prototype.setMessage = function(value) {
153+
proto.LedSignMessage.prototype.setMessage = function(value) {
297154
jspb.Message.setProto3StringField(this, 1, value);
298155
};
299156

proto/led_sign.proto

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ syntax = "proto3";
22

33

44
service LedSign {
5-
rpc HealthCheck (LedSignRequest) returns (LedSignRecord);
6-
rpc UpdateSignText (LedSignRecord) returns (LedSignResponse);
5+
rpc HealthCheck (LedSignMessage) returns (LedSignRecord);
6+
rpc UpdateSignText (LedSignRecord) returns (LedSignMessage);
7+
rpc AddMessageToQueue (LedSignMessage) returns (LedSignMessage);
8+
rpc ClearMessageQueue (LedSignMessage) returns (LedSignMessage);
79
}
810

9-
message LedSignRequest{
10-
string officer_name = 1;
11-
}
12-
13-
message LedSignResponse{
11+
message LedSignMessage{
1412
string message = 1;
1513
}
1614

0 commit comments

Comments
 (0)