mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 08:32:23 +03:00
fix live_chess and encryptor
This commit is contained in:
parent
fb1f469179
commit
38780d3d4f
@ -102,10 +102,10 @@ fn send_http_response(status: u16, headers: HashMap<String, String>, payload_byt
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_ws_update(our_name: String, game: Game) {
|
fn send_ws_update(our: Address, game: Game) {
|
||||||
send_request(
|
send_request(
|
||||||
&Address {
|
&Address {
|
||||||
node: our_name.clone(),
|
node: our.node.clone(),
|
||||||
process: ProcessId::from_str("encryptor:sys:uqbar").unwrap(),
|
process: ProcessId::from_str("encryptor:sys:uqbar").unwrap(),
|
||||||
},
|
},
|
||||||
&Request {
|
&Request {
|
||||||
@ -114,17 +114,19 @@ fn send_ws_update(our_name: String, game: Game) {
|
|||||||
ipc: Some(
|
ipc: Some(
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"EncryptAndForwardAction": {
|
"EncryptAndForwardAction": {
|
||||||
"channel_id": "chess",
|
"channel_id": our.process.to_string(),
|
||||||
"forward_to": {
|
"forward_to": {
|
||||||
"node": our_name.clone(),
|
"node": our.node.clone(),
|
||||||
"process": {
|
"process": {
|
||||||
"Name": "http_server"
|
"process_name": "http_server",
|
||||||
}, // If the message passed in an ID then we could send to just that ID
|
"package_name": "sys",
|
||||||
|
"publisher_node": "uqbar"
|
||||||
|
}
|
||||||
}, // node, process
|
}, // node, process
|
||||||
"json": Some(serde_json::json!({ // this is the JSON to forward
|
"json": Some(serde_json::json!({ // this is the JSON to forward
|
||||||
"WebSocketPush": {
|
"WebSocketPush": {
|
||||||
"target": {
|
"target": {
|
||||||
"node": our_name.clone(),
|
"node": our.node.clone(),
|
||||||
"id": "chess", // If the message passed in an ID then we could send to just that ID
|
"id": "chess", // If the message passed in an ID then we could send to just that ID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,7 +325,7 @@ impl Guest for Component {
|
|||||||
};
|
};
|
||||||
state.games.insert(game_id.clone(), game.clone());
|
state.games.insert(game_id.clone(), game.clone());
|
||||||
|
|
||||||
send_ws_update(our.node.clone(), game.clone());
|
send_ws_update(our.clone(), game.clone());
|
||||||
|
|
||||||
save_chess_state(state.clone());
|
save_chess_state(state.clone());
|
||||||
|
|
||||||
@ -400,7 +402,7 @@ impl Guest for Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
send_ws_update(our.node.clone(), game.clone());
|
send_ws_update(our.clone(), game.clone());
|
||||||
save_chess_state(state.clone());
|
save_chess_state(state.clone());
|
||||||
|
|
||||||
send_response(
|
send_response(
|
||||||
@ -455,7 +457,7 @@ impl Guest for Component {
|
|||||||
state.records.insert(game.id.clone(), (1, 0, 0));
|
state.records.insert(game.id.clone(), (1, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
send_ws_update(our.node.clone(), game.clone());
|
send_ws_update(our.clone(), game.clone());
|
||||||
save_chess_state(state.clone());
|
save_chess_state(state.clone());
|
||||||
|
|
||||||
send_response(
|
send_response(
|
||||||
@ -489,7 +491,7 @@ impl Guest for Component {
|
|||||||
default_headers.clone(),
|
default_headers.clone(),
|
||||||
CHESS_PAGE
|
CHESS_PAGE
|
||||||
.replace("${node}", &our.node)
|
.replace("${node}", &our.node)
|
||||||
.replace("${process}", &source.process.to_string())
|
.replace("${process}", &our.process.to_string())
|
||||||
.replace("${js}", CHESS_JS)
|
.replace("${js}", CHESS_JS)
|
||||||
.replace("${css}", CHESS_CSS)
|
.replace("${css}", CHESS_CSS)
|
||||||
.to_string()
|
.to_string()
|
||||||
|
@ -145,8 +145,10 @@ impl Guest for Component {
|
|||||||
"forward_to": {
|
"forward_to": {
|
||||||
"node": our.node.clone(),
|
"node": our.node.clone(),
|
||||||
"process": {
|
"process": {
|
||||||
"Name": "http_server"
|
"process_name": "http_server",
|
||||||
}, // If the message passed in an ID then we could send to just that ID
|
"package_name": "sys",
|
||||||
|
"publisher_node": "uqbar"
|
||||||
|
}
|
||||||
}, // node, process
|
}, // node, process
|
||||||
"json": Some(serde_json::json!({ // this is the JSON to forward
|
"json": Some(serde_json::json!({ // this is the JSON to forward
|
||||||
"WebSocketPush": {
|
"WebSocketPush": {
|
||||||
|
@ -312,8 +312,10 @@ fn handle_telegram_update(
|
|||||||
"forward_to": {
|
"forward_to": {
|
||||||
"node": our_name.clone(),
|
"node": our_name.clone(),
|
||||||
"process": {
|
"process": {
|
||||||
"Name": "http_server"
|
"process_name": "http_server",
|
||||||
},
|
"package_name": "sys",
|
||||||
|
"publisher_node": "uqbar"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"json": Some(json!({ // this is the JSON to forward
|
"json": Some(json!({ // this is the JSON to forward
|
||||||
"WebSocketPush": {
|
"WebSocketPush": {
|
||||||
|
@ -406,7 +406,7 @@ pub async fn handle_encrypted_ws_message(
|
|||||||
"json": {
|
"json": {
|
||||||
"forwarded_from": {
|
"forwarded_from": {
|
||||||
"node": our.clone(),
|
"node": our.clone(),
|
||||||
"process": "http_server",
|
"process": "http_server:sys:uqbar",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user