echo_grpc_web_pb.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /**
  2. * @fileoverview gRPC-Web generated client stub for echo
  3. * @enhanceable
  4. * @public
  5. */
  6. // GENERATED CODE -- DO NOT EDIT!
  7. const grpc = {};
  8. grpc.web = require('grpc-web');
  9. const proto = {};
  10. proto.echo = require('./echo_pb.js');
  11. /**
  12. * @param {string} hostname
  13. * @param {?Object} credentials
  14. * @param {?Object} options
  15. * @constructor
  16. * @struct
  17. * @final
  18. */
  19. proto.echo.EchoClient =
  20. function(hostname, credentials, options) {
  21. if (!options) options = {};
  22. options['format'] = 'text';
  23. /**
  24. * @private @const {!grpc.web.GrpcWebClientBase} The client
  25. */
  26. this.client_ = new grpc.web.GrpcWebClientBase(options);
  27. /**
  28. * @private @const {string} The hostname
  29. */
  30. this.hostname_ = hostname;
  31. /**
  32. * @private @const {?Object} The credentials to be used to connect
  33. * to the server
  34. */
  35. this.credentials_ = credentials;
  36. /**
  37. * @private @const {?Object} Options for the client
  38. */
  39. this.options_ = options;
  40. };
  41. /**
  42. * @param {string} hostname
  43. * @param {?Object} credentials
  44. * @param {?Object} options
  45. * @constructor
  46. * @struct
  47. * @final
  48. */
  49. proto.echo.EchoPromiseClient =
  50. function(hostname, credentials, options) {
  51. if (!options) options = {};
  52. options['format'] = 'text';
  53. /**
  54. * @private @const {!proto.echo.EchoClient} The delegate callback based client
  55. */
  56. this.delegateClient_ = new proto.echo.EchoClient(
  57. hostname, credentials, options);
  58. };
  59. /**
  60. * @const
  61. * @type {!grpc.web.AbstractClientBase.MethodInfo<
  62. * !proto.echo.EchoRequest,
  63. * !proto.echo.EchoResponse>}
  64. */
  65. const methodInfo_Echo_Get = new grpc.web.AbstractClientBase.MethodInfo(
  66. proto.echo.EchoResponse,
  67. /** @param {!proto.echo.EchoRequest} request */
  68. function(request) {
  69. return request.serializeBinary();
  70. },
  71. proto.echo.EchoResponse.deserializeBinary
  72. );
  73. /**
  74. * @param {!proto.echo.EchoRequest} request The
  75. * request proto
  76. * @param {!Object<string, string>} metadata User defined
  77. * call metadata
  78. * @param {function(?grpc.web.Error, ?proto.echo.EchoResponse)}
  79. * callback The callback function(error, response)
  80. * @return {!grpc.web.ClientReadableStream<!proto.echo.EchoResponse>|undefined}
  81. * The XHR Node Readable Stream
  82. */
  83. proto.echo.EchoClient.prototype.get =
  84. function(request, metadata, callback) {
  85. return this.client_.rpcCall(this.hostname_ +
  86. '/echo.Echo/Get',
  87. request,
  88. metadata,
  89. methodInfo_Echo_Get,
  90. callback);
  91. };
  92. /**
  93. * @param {!proto.echo.EchoRequest} request The
  94. * request proto
  95. * @param {!Object<string, string>} metadata User defined
  96. * call metadata
  97. * @return {!Promise<!proto.echo.EchoResponse>}
  98. * The XHR Node Readable Stream
  99. */
  100. proto.echo.EchoPromiseClient.prototype.get =
  101. function(request, metadata) {
  102. return new Promise((resolve, reject) => {
  103. this.delegateClient_.get(
  104. request, metadata, (error, response) => {
  105. error ? reject(error) : resolve(response);
  106. });
  107. });
  108. };
  109. /**
  110. * @const
  111. * @type {!grpc.web.AbstractClientBase.MethodInfo<
  112. * !proto.echo.EchoRequest,
  113. * !proto.echo.EchoResponse>}
  114. */
  115. const methodInfo_Echo_Expand = new grpc.web.AbstractClientBase.MethodInfo(
  116. proto.echo.EchoResponse,
  117. /** @param {!proto.echo.EchoRequest} request */
  118. function(request) {
  119. return request.serializeBinary();
  120. },
  121. proto.echo.EchoResponse.deserializeBinary
  122. );
  123. /**
  124. * @param {!proto.echo.EchoRequest} request The request proto
  125. * @param {!Object<string, string>} metadata User defined
  126. * call metadata
  127. * @return {!grpc.web.ClientReadableStream<!proto.echo.EchoResponse>}
  128. * The XHR Node Readable Stream
  129. */
  130. proto.echo.EchoClient.prototype.expand =
  131. function(request, metadata) {
  132. return this.client_.serverStreaming(this.hostname_ +
  133. '/echo.Echo/Expand',
  134. request,
  135. metadata,
  136. methodInfo_Echo_Expand);
  137. };
  138. /**
  139. * @param {!proto.echo.EchoRequest} request The request proto
  140. * @param {!Object<string, string>} metadata User defined
  141. * call metadata
  142. * @return {!grpc.web.ClientReadableStream<!proto.echo.EchoResponse>}
  143. * The XHR Node Readable Stream
  144. */
  145. proto.echo.EchoPromiseClient.prototype.expand =
  146. function(request, metadata) {
  147. return this.delegateClient_.client_.serverStreaming(this.delegateClient_.hostname_ +
  148. '/echo.Echo/Expand',
  149. request,
  150. metadata,
  151. methodInfo_Echo_Expand);
  152. };
  153. module.exports = proto.echo;