extern crate failure;
extern crate protocols;
#[macro_use] extern crate serde_json;
use std::net::UdpSocket;
use protocols::pluginmanager::PluginManager;
fn main() -> Result<(), failure::Error> {
let manager = PluginManager::new();
manager.load_single_plugin("./libraries/test-protocol/target/debug/test_protocol.dll")?;
manager.load_single_plugin("./libraries/root-message/target/debug/root_message.dll")?;
let root_protocol_hash = include_str!("../libraries/root-message/hash.txt");
let test_protocol_hash = include_str!("../libraries/test-protocol/hash.txt");
println!("Getting default message...");
let mut root_data = manager.get_default_json_message(root_protocol_hash)?;
let mut test_data = manager.get_default_json_message(test_protocol_hash)?;
println!("Constructing message...");
test_data["name"] = json!("Test Name");
test_data["data"] = json!("Test Data");
root_data["schema_location"] = json!(test_protocol_hash); root_data["unencrypted_message"] = json!(test_data.to_string().as_bytes());
println!("Sending: {:?}", root_data);
let socket = UdpSocket::bind("127.0.0.1:61945")?; socket.send_to(root_data.to_string().as_bytes(), "127.0.0.1:23462")?;
Ok(())
}