Class GrpcContext
java.lang.Object
com.codename1.backend.grpc.GrpcContext
What a gRPC handler can learn about its call and add to the answer: the request metadata, the deadline, whether the client went away, and response headers and trailers.
Declare it as the last parameter of a @GrpcService method to receive it.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddBinaryTrailer(String name, byte[] value) Adds a binary response trailer.voidAdds a response header.voidaddTrailer(String name, String value) Adds a response trailer, sent with the status.A request metadata value.byte[]A binary request metadata value, decoded.longbooleanboolean
-
Method Details
-
getMethod
- Returns:
- the full method name,
/package.Service/Method
-
get
A request metadata value. Names are lower case; a binary (-bin) value is returned as the base64 text it was sent as, seegetBinary(String).- Parameters:
name- the header name- Returns:
- the value or null
-
getBinary
A binary request metadata value, decoded.- Parameters:
name- a name ending in-bin- Returns:
- the bytes, or null when absent or not base64
-
getMetadata
-
getRemainingMillis
public long getRemainingMillis()- Returns:
- milliseconds until the client's deadline, or -1 without one; 0 once it has passed
-
isDeadlineExceeded
public boolean isDeadlineExceeded()- Returns:
- whether the deadline has passed
-
isCancelled
public boolean isCancelled()- Returns:
- whether the client cancelled or the stream was reset
-
addHeader
-
addTrailer
-
addBinaryTrailer
Adds a binary response trailer.- Parameters:
name- a name ending in-binvalue- the bytes
-