demo code, needs some work to be more stable
This commit is contained in:
@@ -16,6 +16,7 @@ pub struct Context {
|
||||
|
||||
impl Context {
|
||||
pub fn new(url: &str, cfg: Cfg) -> Context {
|
||||
info!("Connecting to web socket server @ {}", url);
|
||||
let (sender, reciever) = ewebsock::connect(url, ewebsock::Options::default()).unwrap();
|
||||
|
||||
Self {
|
||||
@@ -42,11 +43,7 @@ impl Context {
|
||||
None
|
||||
}
|
||||
WsEvent::Message(ws_message) => match ws_message {
|
||||
ewebsock::WsMessage::Text(msg) => {
|
||||
let game_resp: T = serde_json::from_str(&msg).unwrap();
|
||||
|
||||
Some(game_resp)
|
||||
}
|
||||
ewebsock::WsMessage::Text(msg) => serde_json::from_str(&msg).ok(),
|
||||
_ => None,
|
||||
},
|
||||
WsEvent::Error(err) => {
|
||||
|
||||
Reference in New Issue
Block a user