Browse Source

fix the standalone binaries

pull/121/head
jake 2 years ago
parent
commit
3a50cd7ba1
  1. 25
      src/bin/login.rs
  2. 144
      src/bin/main.rs
  3. 8
      src/bin/patch.rs
  4. 21
      src/bin/ship.rs

25
src/bin/login.rs

@ -1,12 +1,10 @@
use log::{info};
//use elseware::entity::gateway::postgres::PostgresGateway;
use elseware::entity::gateway::postgres::PostgresGateway;
use elseware::login::login::LoginServerState;
use elseware::login::character::CharacterServerState;
//use elseware::common::mainloop::{login_mainloop, character_mainloop};
//use elseware::common::interserver::AuthToken;
use elseware::common::interserver::AuthToken;
fn main() {
/*
let colors = fern::colors::ColoredLevelConfig::new()
.error(fern::colors::Color::Red)
.warn(fern::colors::Color::Yellow)
@ -38,16 +36,23 @@ fn main() {
let shipgate_token = std::env::var("SHIPGATE_TOKEN").unwrap();
let entity_gateway = PostgresGateway::new(&db_host, &db_dbname, &db_username, &db_password);
let thread_entity_gateway = entity_gateway.clone();
let login_state = LoginServerState::new(thread_entity_gateway, charserv_ip);
let login_loop = login_mainloop(login_state, elseware::login::login::LOGIN_PORT);
let login_state = LoginServerState::new(entity_gateway.clone(), charserv_ip);
let login_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(login_state, elseware::login::login::LOGIN_PORT).await;
});
let char_state = CharacterServerState::new(entity_gateway, AuthToken(shipgate_token));
let character_loop = character_mainloop(char_state, elseware::login::character::CHARACTER_PORT, elseware::login::login::COMMUNICATION_PORT);
let sub_char_state = char_state.clone();
let character_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(sub_char_state, elseware::login::character::CHARACTER_PORT).await;
});
let inter_character_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_interserver_listen(char_state, elseware::login::login::COMMUNICATION_PORT).await;
});
info!("[auth/character] starting server");
async_std::task::block_on(async move {
futures::future::join_all(vec![login_loop, character_loop]).await
futures::future::join_all(vec![login_loop, character_loop, inter_character_loop]).await
});
*/
}

144
src/bin/main.rs

@ -1,21 +1,18 @@
use std::net::Ipv4Addr;
use log::{info};
use async_std::channel;
use elseware::patch::patch::{PatchServerState, generate_patch_tree, load_config, load_motd};
use elseware::common::interserver::AuthToken;
use elseware::login::login::LoginServerState;
use elseware::login::character::CharacterServerState;
//use elseware::ship::ship::ShipServerStateBuilder;
use elseware::entity::account::{NewUserAccountEntity, NewUserSettingsEntity};
use elseware::patch::patch::{PatchServerState, generate_patch_tree, load_config, load_motd};
use elseware::ship::ship::ShipServerStateBuilder;
#[allow(unused_imports)]
//use elseware::entity::gateway::{EntityGateway, InMemoryGateway, PostgresGateway};
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
use elseware::entity::gateway::{EntityGateway, InMemoryGateway, PostgresGateway};
use elseware::entity::account::{NewUserAccountEntity, NewUserSettingsEntity};
use elseware::entity::character::NewCharacterEntity;
use elseware::entity::item::{NewItemEntity, ItemDetail, InventoryItemEntity};
use elseware::common::interserver::AuthToken;
use elseware::entity::item;
use elseware::common::mainloop::*;
fn setup_logger() {
let colors = fern::colors::ColoredLevelConfig::new()
@ -327,60 +324,14 @@ fn main() {
};
entity_gateway.set_character_equips(&character.id, &equipped).await.unwrap();
let inventory = item::InventoryEntity::new(vec![InventoryItemEntity::from(item0), item1.into(), item2_w.into(), item3.into(), item4.into(), item5_m.into(), item6.into(), item6_1.into(), item7_a.into(), item8_s.into(), item9_u0.into(), item10_u1.into(), item11_u2.into(), item12_u3.into(), item13.into(), item14.into(), monomates.into()]);
let inventory = item::InventoryEntity::new(vec![InventoryItemEntity::from(item0), item1.into(), item2_w.into(), item3.into(),
item4.into(), item5_m.into(), item6.into(), item6_1.into(), item7_a.into(),
item8_s.into(), item9_u0.into(), item10_u1.into(), item11_u2.into(), item12_u3.into(),
item13.into(), item14.into(), monomates.into()]);
entity_gateway.set_character_inventory(&character.id, &inventory).await.unwrap();
entity_gateway.set_character_bank(&character.id, &item::BankEntity::default(), &item::BankName("".into())).await.unwrap();
}
/*
info!("[patch] starting server");
let patch_config = load_config();
let patch_motd = load_motd();
let (patch_file_tree, patch_file_lookup) = generate_patch_tree(patch_config.path.as_str());
let patch_state = Box::new(PatchServerState::new(patch_file_tree, patch_file_lookup, patch_motd));
let patch_loop = patch_mainloop(*patch_state, patch_config.port);
let thread_entity_gateway = entity_gateway.clone();
info!("[auth] starting server");
let login_state = Box::new(LoginServerState::new(thread_entity_gateway, "127.0.0.1".parse().unwrap()));
let login_loop = login_mainloop(*login_state, elseware::login::login::LOGIN_PORT);
let thread_entity_gateway = entity_gateway.clone();
info!("[character] starting server");
let char_state = Box::new(CharacterServerState::new(thread_entity_gateway, AuthToken("".into())));
let character_loop = character_mainloop(*char_state, elseware::login::character::CHARACTER_PORT, elseware::login::login::COMMUNICATION_PORT);
let thread_entity_gateway = entity_gateway.clone();
info!("[ship] starting server");
let ship_state = Box::new(ShipServerStateBuilder::default()
.name("US/Sona-Nyl".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT)
.gateway(thread_entity_gateway)
.build());
let ship_loop = ship_mainloop(*ship_state, elseware::ship::ship::SHIP_PORT, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT);
let thread_entity_gateway = entity_gateway.clone();
let ship_state = Box::new(ShipServerStateBuilder::default()
.name("EU/Dylath-Leen".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT+2000)
.gateway(thread_entity_gateway)
.build());
let ship_loop2 = ship_mainloop(*ship_state, elseware::ship::ship::SHIP_PORT+2000, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT);
let thread_entity_gateway = entity_gateway.clone();
let ship_state = Box::new(ShipServerStateBuilder::default()
.name("JP/Thalarion".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT+3000)
.gateway(thread_entity_gateway)
.build());
let ship_loop3 = ship_mainloop(*ship_state, elseware::ship::ship::SHIP_PORT+3000, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT);
futures::future::join_all(vec![patch_loop, login_loop, character_loop, ship_loop, ship_loop2, ship_loop3]).await;
*/
info!("[patch] starting server");
let patch_config = load_config();
let patch_motd = load_motd();
@ -391,15 +342,13 @@ fn main() {
});
info!("[auth] starting server");
let auth_entity_gateway = entity_gateway.clone();
let login_state = LoginServerState::new(auth_entity_gateway, "127.0.0.1".parse().unwrap());
let login_state = LoginServerState::new(entity_gateway.clone(), "127.0.0.1".parse().unwrap());
let login_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(login_state, elseware::login::login::LOGIN_PORT).await;
});
info!("[character] starting server");
let character_entity_gateway = entity_gateway.clone();
let char_state = CharacterServerState::new(character_entity_gateway, AuthToken("".into()));
let char_state = CharacterServerState::new(entity_gateway.clone(), AuthToken("".into()));
let sub_char_state = char_state.clone();
let character_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(sub_char_state, elseware::login::character::CHARACTER_PORT).await;
@ -409,66 +358,55 @@ fn main() {
let inter_character_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_interserver_listen(sub_char_state, elseware::login::login::COMMUNICATION_PORT).await;
});
/*
let inter_character_loop_recv = async_std::task::spawn(|| async {
crate::common::mainloop::run_interserver_receiver(char_state, elseware::login::character::COMMUNICATION_PORT).await
});
let inter_character_loop_send = async_std::task::spawn(|| async {
crate::common::mainloop::run_interserver_sender(char_state, interserver_rx).await
*/
let ship_entity_gateway = entity_gateway.clone();
info!("[ship] starting server");
//let (interserver_tx, interserver_rx) = async_std::channel::unbounded();
/*
info!("[ship] starting servers");
let ship_state = ShipServerStateBuilder::default()
.name("US/Sona-Nyl".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT)
.gateway(thread_entity_gateway)
.interserver_sender(|msg| async move {
interserver_tx.send(msg).await
})
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop = async_std::task::spawn(|| async {
crate::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT);
let ship_loop1 = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT).await;
});
/*
/*, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT*/
let inter_ship_loop = async_std::task::spawn(|| async {
crate::common::mainloop::run_interserver_receiver(ship_state, elseware::login::login::COMMUNICATION_PORT);
let sub_ship_state = ship_state.clone();
let inter_ship_loop1 = async_std::task::spawn(async move {
elseware::common::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
});
*/
let ship_entity_gateway = entity_gateway.clone();
let ship_state = Box::new(ShipServerStateBuilder::default()
let ship_state = ShipServerStateBuilder::default()
.name("EU/Dylath-Leen".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT+2000)
.gateway(thread_entity_gateway)
.build());
.port(elseware::ship::ship::SHIP_PORT+200)
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop2 = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT+2000).await;
});
let sub_ship_state = ship_state.clone();
let ship_loop2 = async_std::task::spawn(|| async {
crate::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT);
let inter_ship_loop2 = async_std::task::spawn(async move {
elseware::common::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
});
let thread_entity_gateway = entity_gateway.clone();
let ship_state = Box::new(ShipServerStateBuilder::default()
let ship_state = ShipServerStateBuilder::default()
.name("JP/Thalarion".into())
.ip(Ipv4Addr::new(127,0,0,1))
.port(elseware::ship::ship::SHIP_PORT+3000)
.gateway(thread_entity_gateway)
.build());
.gateway(entity_gateway.clone())
.build();
let sub_ship_state = ship_state.clone();
let ship_loop3 = async_std::task::spawn(|| async {
crate::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT);
let ship_loop3 = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT+3000).await;
});
let sub_ship_state = ship_state.clone();
let inter_ship_loop3 = async_std::task::spawn(async move {
elseware::common::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await;
});
futures::future::join_all(vec![patch_loop, login_loop, character_loop, ship_loop, ship_loop2, ship_loop3]).await;
*/
futures::future::join_all(vec![patch_loop, login_loop, character_loop, inter_character_loop]).await;
futures::future::join_all(vec![patch_loop, login_loop, character_loop, inter_character_loop,
ship_loop1, ship_loop2, ship_loop3,
inter_ship_loop1, inter_ship_loop2, inter_ship_loop3]).await;
});
}

8
src/bin/patch.rs

@ -1,18 +1,18 @@
use elseware::patch::patch::{PatchServerState, generate_patch_tree, load_config_env, load_motd};
use log::{info};
//use elseware::common::mainloop::patch_mainloop;
fn main() {
/*
info!("[patch] starting server");
let patch_config = load_config_env();
let patch_motd = load_motd();
let (patch_file_tree, patch_file_lookup) = generate_patch_tree(patch_config.path.as_str());
let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup, patch_motd);
let patch_loop = patch_mainloop(patch_state, patch_config.port);
let patch_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(patch_state, patch_config.port).await;
});
async_std::task::block_on(async move {
patch_loop.await
});
*/
}

21
src/bin/ship.rs

@ -1,11 +1,9 @@
use log::{info};
//use elseware::entity::gateway::postgres::PostgresGateway;
//use elseware::ship::ship::ShipServerStateBuilder;
//use elseware::common::mainloop::ship_mainloop;
//use elseware::common::interserver::AuthToken;
use elseware::entity::gateway::postgres::PostgresGateway;
use elseware::ship::ship::ShipServerStateBuilder;
use elseware::common::interserver::AuthToken;
fn main() {
/*
let colors = fern::colors::ColoredLevelConfig::new()
.error(fern::colors::Color::Red)
.warn(fern::colors::Color::Yellow)
@ -38,6 +36,7 @@ fn main() {
let shipgate_token = std::env::var("SHIPGATE_TOKEN").unwrap();
let ship_name = std::env::var("SHIP_NAME").unwrap().parse().unwrap();
let ip = std::env::var("SELF_IP").unwrap().parse().unwrap();
let ship_state = ShipServerStateBuilder::default()
.name(ship_name)
.ip(ip)
@ -47,11 +46,17 @@ fn main() {
.build();
let shipgate_ip = std::env::var("SHIPGATE_IP").unwrap().parse().unwrap();
let ship_loop = ship_mainloop(ship_state, elseware::ship::ship::SHIP_PORT, shipgate_ip, elseware::login::login::COMMUNICATION_PORT);
let sub_ship_state = ship_state.clone();
let ship_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT).await;
});
let inter_ship_loop = async_std::task::spawn(async move {
elseware::common::mainloop::run_interserver_connect(ship_state, shipgate_ip, elseware::login::login::COMMUNICATION_PORT).await;
});
info!("[auth/character] starting server");
async_std::task::block_on(async move {
ship_loop.await
futures::future::join_all(vec![ship_loop, inter_ship_loop]).await;
});
*/
}
Loading…
Cancel
Save