26 lines
642 B
Rust
26 lines
642 B
Rust
|
use anyhow::{Context, Error, Result};
|
||
|
use super::*;
|
||
|
use futures::prelude::*;
|
||
|
use serde_json::{Value, json};
|
||
|
use stream::iter;
|
||
|
|
||
|
pub async fn greet<T>(sink: &mut T) -> Result<()>
|
||
|
where T: Sink<ServerMessage<Vec<Value>, Value>, Error = Error> + Unpin
|
||
|
{
|
||
|
let mut greeting = iter(vec![
|
||
|
ServerMessage::Meta {
|
||
|
m: Meta {
|
||
|
version: "Unstable",
|
||
|
helo: Some("Dedicated base2020 server".into()),
|
||
|
},
|
||
|
},
|
||
|
ServerMessage::SetState {
|
||
|
u: 0,
|
||
|
s: json!({}),
|
||
|
},
|
||
|
])
|
||
|
.map(Ok);
|
||
|
|
||
|
sink.send_all(&mut greeting).await.context("Greeting client")
|
||
|
}
|