mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
draft gemini socket connection
This commit is contained in:
parent
e0ecb8ed8a
commit
6cb2f0ebea
1 changed files with 59 additions and 3 deletions
|
|
@ -5,8 +5,9 @@ use content::Content;
|
||||||
use navigation::Navigation;
|
use navigation::Navigation;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
glib::{GString, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags},
|
gio::{Cancellable, SocketClient, SocketProtocol, TlsCertificateFlags},
|
||||||
prelude::BoxExt,
|
glib::{GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags},
|
||||||
|
prelude::{BoxExt, IOStreamExt, InputStreamExtManual, OutputStreamExtManual, SocketClientExt},
|
||||||
Box, Orientation,
|
Box, Orientation,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -52,7 +53,62 @@ impl Page {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
"gemini" => {
|
"gemini" => {
|
||||||
todo!()
|
let client = SocketClient::new();
|
||||||
|
|
||||||
|
client.set_tls(true);
|
||||||
|
client.set_tls_validation_flags(TlsCertificateFlags::INSECURE);
|
||||||
|
client.set_protocol(SocketProtocol::Tcp);
|
||||||
|
|
||||||
|
client.connect_to_uri_async(
|
||||||
|
"gemini://geminiprotocol.net:1965/", // @TODO &uri.to_str(),
|
||||||
|
1965,
|
||||||
|
Some(&Cancellable::new()),
|
||||||
|
move |result| match result {
|
||||||
|
Ok(connection) => {
|
||||||
|
connection.output_stream().write_all_async(
|
||||||
|
"gemini://geminiprotocol.net:1965/\r\n", // @TODO
|
||||||
|
Priority::DEFAULT,
|
||||||
|
Some(&Cancellable::new()),
|
||||||
|
move |result| match result {
|
||||||
|
Ok(request) => {
|
||||||
|
println!(
|
||||||
|
"Request sent successfully: {:?}",
|
||||||
|
request
|
||||||
|
); // @TODO remove
|
||||||
|
|
||||||
|
connection.input_stream().read_all_async(
|
||||||
|
Vec::new(),
|
||||||
|
Priority::DEFAULT,
|
||||||
|
Some(&Cancellable::new()),
|
||||||
|
{
|
||||||
|
|result| match result {
|
||||||
|
Ok(response) => {
|
||||||
|
println!("Result: {:?}", response);
|
||||||
|
|
||||||
|
// @TODO connection.close(cancellable);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!(
|
||||||
|
"Failed to read response: {:?}",
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Failed to write request: {:?}", e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Failed to connect: {e}"); // @TODO
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
"nex" => {
|
"nex" => {
|
||||||
todo!()
|
todo!()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue