mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
dchat: renamed message to msg and removed unnecessary util methods
This commit is contained in:
@@ -4,8 +4,6 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "Demo chat to document darkfi net code"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
darkfi = {path = "../../", features = ["net", "rpc"]}
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ impl net::Message for Dchatmsg {
|
||||
|
||||
#[derive(Debug, Clone, SerialEncodable, SerialDecodable)]
|
||||
pub struct Dchatmsg {
|
||||
pub message: String,
|
||||
pub msg: String,
|
||||
}
|
||||
|
||||
@@ -13,11 +13,7 @@ use url::Url;
|
||||
|
||||
use termion::{event::Key, input::TermRead, raw::IntoRawMode};
|
||||
|
||||
use darkfi::{
|
||||
net,
|
||||
net::Settings,
|
||||
util::cli::{get_log_config, get_log_level},
|
||||
};
|
||||
use darkfi::{net, net::Settings};
|
||||
|
||||
use crate::{
|
||||
dchatmsg::{Dchatmsg, DchatmsgsBuffer},
|
||||
@@ -161,14 +157,14 @@ impl Dchat {
|
||||
DisplayMode::Inbox => {
|
||||
let msgs = self.recv_msgs.lock().await;
|
||||
for i in msgs.iter() {
|
||||
if !i.message.is_empty() {
|
||||
if !i.msg.is_empty() {
|
||||
write!(
|
||||
stdout,
|
||||
"{}{}{}received msg: {}",
|
||||
termion::clear::All,
|
||||
termion::style::Bold,
|
||||
termion::cursor::Goto(1, 2),
|
||||
i.message
|
||||
i.msg
|
||||
)?;
|
||||
} else {
|
||||
write!(
|
||||
@@ -238,8 +234,8 @@ impl Dchat {
|
||||
}
|
||||
|
||||
async fn send(&self) -> Result<()> {
|
||||
let message = self.input.clone();
|
||||
let dchatmsg = Dchatmsg { message };
|
||||
let msg = self.input.clone();
|
||||
let dchatmsg = Dchatmsg { msg };
|
||||
self.p2p.broadcast(dchatmsg).await?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -294,8 +290,8 @@ fn bob() -> Result<Settings> {
|
||||
|
||||
#[async_std::main]
|
||||
async fn main() -> Result<()> {
|
||||
let log_level = get_log_level(1);
|
||||
let log_config = get_log_config();
|
||||
let log_level = simplelog::LevelFilter::Debug;
|
||||
let log_config = simplelog::Config::default();
|
||||
|
||||
let log_path = "/tmp/dchat.log";
|
||||
let file = File::create(log_path).unwrap();
|
||||
@@ -318,7 +314,7 @@ async fn main() -> Result<()> {
|
||||
let ex = Arc::new(Executor::new());
|
||||
let ex2 = ex.clone();
|
||||
|
||||
let msgs: DchatmsgsBuffer = Arc::new(Mutex::new(vec![Dchatmsg { message: String::new() }]));
|
||||
let msgs: DchatmsgsBuffer = Arc::new(Mutex::new(vec![Dchatmsg { msg: String::new() }]));
|
||||
|
||||
let mut dchat = Dchat::new(p2p, msgs, String::new(), DisplayMode::Normal);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user