1#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Msg {
5 #[prost(int64, tag = "1")]
7 pub sender_uid: i64,
8 #[prost(int32, tag = "2")]
10 pub receiver_type: i32,
11 #[prost(int64, tag = "3")]
13 pub receiver_id: i64,
14 #[prost(int64, tag = "4")]
16 pub cli_msg_id: i64,
17 #[prost(int32, tag = "5")]
19 pub msg_type: i32,
20 #[prost(string, tag = "6")]
22 pub content: ::prost::alloc::string::String,
23 #[prost(int64, tag = "7")]
25 pub msg_seqno: i64,
26 #[prost(int64, tag = "8")]
28 pub timestamp: i64,
29 #[prost(int64, repeated, tag = "9")]
31 pub at_uids: ::prost::alloc::vec::Vec<i64>,
32 #[prost(int64, repeated, tag = "10")]
34 pub recver_ids: ::prost::alloc::vec::Vec<i64>,
35 #[prost(int64, tag = "11")]
37 pub msg_key: i64,
38 #[prost(int32, tag = "12")]
40 pub msg_status: i32,
41 #[prost(bool, tag = "13")]
43 pub sys_cancel: bool,
44 #[prost(int32, tag = "14")]
46 pub is_multi_chat: i32,
47 #[prost(int64, tag = "15")]
49 pub withdraw_seqno: i64,
50 #[prost(string, tag = "16")]
52 pub notify_code: ::prost::alloc::string::String,
53 #[prost(int32, tag = "17")]
55 pub msg_source: i32,
56}
57#[derive(Clone, Copy, PartialEq, ::prost::Message)]
59pub struct NotifyInfo {
60 #[prost(int32, tag = "1")]
62 pub msg_type: i32,
63 #[prost(int64, tag = "2")]
65 pub talker_id: i64,
66 #[prost(int32, tag = "3")]
68 pub session_type: i32,
69}
70#[derive(Clone, PartialEq, ::prost::Message)]
72pub struct NotifyRsp {
73 #[prost(int64, tag = "1")]
75 pub uid: i64,
76 #[prost(int64, tag = "2")]
78 pub cmd: i64,
79 #[prost(bytes = "vec", tag = "3")]
81 pub payload: ::prost::alloc::vec::Vec<u8>,
82 #[prost(enumeration = "PlType", tag = "4")]
84 pub payload_type: i32,
85}
86#[derive(Clone, PartialEq, ::prost::Message)]
88pub struct ReqServerNotify {
89 #[prost(int64, tag = "1")]
91 pub lastest_seqno: i64,
92 #[prost(message, optional, tag = "2")]
94 pub instant_msg: ::core::option::Option<Msg>,
95 #[prost(message, optional, tag = "3")]
97 pub notify_info: ::core::option::Option<NotifyInfo>,
98}
99#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
101#[repr(i32)]
102pub enum CmdId {
103 EnCmdIdInvalid = 0,
105 EnCmdIdMsgNotify = 1,
107 EnCmdIdKickOut = 2,
109}
110impl CmdId {
111 pub fn as_str_name(&self) -> &'static str {
116 match self {
117 Self::EnCmdIdInvalid => "EN_CMD_ID_INVALID",
118 Self::EnCmdIdMsgNotify => "EN_CMD_ID_MSG_NOTIFY",
119 Self::EnCmdIdKickOut => "EN_CMD_ID_KICK_OUT",
120 }
121 }
122 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
124 match value {
125 "EN_CMD_ID_INVALID" => Some(Self::EnCmdIdInvalid),
126 "EN_CMD_ID_MSG_NOTIFY" => Some(Self::EnCmdIdMsgNotify),
127 "EN_CMD_ID_KICK_OUT" => Some(Self::EnCmdIdKickOut),
128 _ => None,
129 }
130 }
131}
132#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
134#[repr(i32)]
135pub enum PlType {
136 EnPayloadNormal = 0,
138 EnPayloadBase64 = 1,
140}
141impl PlType {
142 pub fn as_str_name(&self) -> &'static str {
147 match self {
148 Self::EnPayloadNormal => "EN_PAYLOAD_NORMAL",
149 Self::EnPayloadBase64 => "EN_PAYLOAD_BASE64",
150 }
151 }
152 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
154 match value {
155 "EN_PAYLOAD_NORMAL" => Some(Self::EnPayloadNormal),
156 "EN_PAYLOAD_BASE64" => Some(Self::EnPayloadBase64),
157 _ => None,
158 }
159 }
160}
161pub mod notify_client {
163 #![allow(
164 unused_variables,
165 dead_code,
166 missing_docs,
167 clippy::wildcard_imports,
168 clippy::let_unit_value,
169 )]
170 use tonic::codegen::*;
171 use tonic::codegen::http::Uri;
172 #[derive(Debug, Clone)]
174 pub struct NotifyClient<T> {
175 inner: tonic::client::Grpc<T>,
176 }
177 impl<T> NotifyClient<T>
178 where
179 T: tonic::client::GrpcService<tonic::body::BoxBody>,
180 T::Error: Into<StdError>,
181 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
182 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
183 {
184 pub fn new(inner: T) -> Self {
185 let inner = tonic::client::Grpc::new(inner);
186 Self { inner }
187 }
188 pub fn with_origin(inner: T, origin: Uri) -> Self {
189 let inner = tonic::client::Grpc::with_origin(inner, origin);
190 Self { inner }
191 }
192 pub fn with_interceptor<F>(
193 inner: T,
194 interceptor: F,
195 ) -> NotifyClient<InterceptedService<T, F>>
196 where
197 F: tonic::service::Interceptor,
198 T::ResponseBody: Default,
199 T: tonic::codegen::Service<
200 http::Request<tonic::body::BoxBody>,
201 Response = http::Response<
202 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
203 >,
204 >,
205 <T as tonic::codegen::Service<
206 http::Request<tonic::body::BoxBody>,
207 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
208 {
209 NotifyClient::new(InterceptedService::new(inner, interceptor))
210 }
211 #[must_use]
216 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
217 self.inner = self.inner.send_compressed(encoding);
218 self
219 }
220 #[must_use]
222 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
223 self.inner = self.inner.accept_compressed(encoding);
224 self
225 }
226 #[must_use]
230 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
231 self.inner = self.inner.max_decoding_message_size(limit);
232 self
233 }
234 #[must_use]
238 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
239 self.inner = self.inner.max_encoding_message_size(limit);
240 self
241 }
242 pub async fn watch_notify(
244 &mut self,
245 request: impl tonic::IntoRequest<()>,
246 ) -> std::result::Result<tonic::Response<super::NotifyRsp>, tonic::Status> {
247 self.inner
248 .ready()
249 .await
250 .map_err(|e| {
251 tonic::Status::unknown(
252 format!("Service was not ready: {}", e.into()),
253 )
254 })?;
255 let codec = tonic::codec::ProstCodec::default();
256 let path = http::uri::PathAndQuery::from_static(
257 "/bilibili.broadcast.message.im.Notify/WatchNotify",
258 );
259 let mut req = request.into_request();
260 req.extensions_mut()
261 .insert(
262 GrpcMethod::new(
263 "bilibili.broadcast.message.im.Notify",
264 "WatchNotify",
265 ),
266 );
267 self.inner.unary(req, path, codec).await
268 }
269 }
270}
271pub mod notify_server {
273 #![allow(
274 unused_variables,
275 dead_code,
276 missing_docs,
277 clippy::wildcard_imports,
278 clippy::let_unit_value,
279 )]
280 use tonic::codegen::*;
281 #[async_trait]
283 pub trait Notify: std::marker::Send + std::marker::Sync + 'static {
284 async fn watch_notify(
286 &self,
287 request: tonic::Request<()>,
288 ) -> std::result::Result<tonic::Response<super::NotifyRsp>, tonic::Status>;
289 }
290 #[derive(Debug)]
292 pub struct NotifyServer<T> {
293 inner: Arc<T>,
294 accept_compression_encodings: EnabledCompressionEncodings,
295 send_compression_encodings: EnabledCompressionEncodings,
296 max_decoding_message_size: Option<usize>,
297 max_encoding_message_size: Option<usize>,
298 }
299 impl<T> NotifyServer<T> {
300 pub fn new(inner: T) -> Self {
301 Self::from_arc(Arc::new(inner))
302 }
303 pub fn from_arc(inner: Arc<T>) -> Self {
304 Self {
305 inner,
306 accept_compression_encodings: Default::default(),
307 send_compression_encodings: Default::default(),
308 max_decoding_message_size: None,
309 max_encoding_message_size: None,
310 }
311 }
312 pub fn with_interceptor<F>(
313 inner: T,
314 interceptor: F,
315 ) -> InterceptedService<Self, F>
316 where
317 F: tonic::service::Interceptor,
318 {
319 InterceptedService::new(Self::new(inner), interceptor)
320 }
321 #[must_use]
323 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
324 self.accept_compression_encodings.enable(encoding);
325 self
326 }
327 #[must_use]
329 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
330 self.send_compression_encodings.enable(encoding);
331 self
332 }
333 #[must_use]
337 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
338 self.max_decoding_message_size = Some(limit);
339 self
340 }
341 #[must_use]
345 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
346 self.max_encoding_message_size = Some(limit);
347 self
348 }
349 }
350 impl<T, B> tonic::codegen::Service<http::Request<B>> for NotifyServer<T>
351 where
352 T: Notify,
353 B: Body + std::marker::Send + 'static,
354 B::Error: Into<StdError> + std::marker::Send + 'static,
355 {
356 type Response = http::Response<tonic::body::BoxBody>;
357 type Error = std::convert::Infallible;
358 type Future = BoxFuture<Self::Response, Self::Error>;
359 fn poll_ready(
360 &mut self,
361 _cx: &mut Context<'_>,
362 ) -> Poll<std::result::Result<(), Self::Error>> {
363 Poll::Ready(Ok(()))
364 }
365 fn call(&mut self, req: http::Request<B>) -> Self::Future {
366 match req.uri().path() {
367 "/bilibili.broadcast.message.im.Notify/WatchNotify" => {
368 #[allow(non_camel_case_types)]
369 struct WatchNotifySvc<T: Notify>(pub Arc<T>);
370 impl<T: Notify> tonic::server::UnaryService<()>
371 for WatchNotifySvc<T> {
372 type Response = super::NotifyRsp;
373 type Future = BoxFuture<
374 tonic::Response<Self::Response>,
375 tonic::Status,
376 >;
377 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
378 let inner = Arc::clone(&self.0);
379 let fut = async move {
380 <T as Notify>::watch_notify(&inner, request).await
381 };
382 Box::pin(fut)
383 }
384 }
385 let accept_compression_encodings = self.accept_compression_encodings;
386 let send_compression_encodings = self.send_compression_encodings;
387 let max_decoding_message_size = self.max_decoding_message_size;
388 let max_encoding_message_size = self.max_encoding_message_size;
389 let inner = self.inner.clone();
390 let fut = async move {
391 let method = WatchNotifySvc(inner);
392 let codec = tonic::codec::ProstCodec::default();
393 let mut grpc = tonic::server::Grpc::new(codec)
394 .apply_compression_config(
395 accept_compression_encodings,
396 send_compression_encodings,
397 )
398 .apply_max_message_size_config(
399 max_decoding_message_size,
400 max_encoding_message_size,
401 );
402 let res = grpc.unary(method, req).await;
403 Ok(res)
404 };
405 Box::pin(fut)
406 }
407 _ => {
408 Box::pin(async move {
409 let mut response = http::Response::new(empty_body());
410 let headers = response.headers_mut();
411 headers
412 .insert(
413 tonic::Status::GRPC_STATUS,
414 (tonic::Code::Unimplemented as i32).into(),
415 );
416 headers
417 .insert(
418 http::header::CONTENT_TYPE,
419 tonic::metadata::GRPC_CONTENT_TYPE,
420 );
421 Ok(response)
422 })
423 }
424 }
425 }
426 }
427 impl<T> Clone for NotifyServer<T> {
428 fn clone(&self) -> Self {
429 let inner = self.inner.clone();
430 Self {
431 inner,
432 accept_compression_encodings: self.accept_compression_encodings,
433 send_compression_encodings: self.send_compression_encodings,
434 max_decoding_message_size: self.max_decoding_message_size,
435 max_encoding_message_size: self.max_encoding_message_size,
436 }
437 }
438 }
439 pub const SERVICE_NAME: &str = "bilibili.broadcast.message.im.Notify";
441 impl<T> tonic::server::NamedService for NotifyServer<T> {
442 const NAME: &'static str = SERVICE_NAME;
443 }
444}