unequipClick(e)} onMouseOver={e => hoverInfo(e, 'equipSkills')} >
diff --git a/server/src/net.rs b/server/src/net.rs
index e55915f9..86b162ad 100644
--- a/server/src/net.rs
+++ b/server/src/net.rs
@@ -9,8 +9,6 @@ use serde_cbor::{to_vec};
use std::env;
use std::thread::{spawn, sleep};
use std::time::{Instant, Duration};
-use std::any::Any;
-use std::panic;
use r2d2::{Pool};
use r2d2::{PooledConnection};
@@ -35,8 +33,8 @@ struct RpcErrorResponse {
err: String
}
-fn receive(db: Db, rpc: &Rpc, msg: Message, client: &mut WebSocket
) -> Result {
- match rpc.receive(msg, &db, client) {
+fn receive(db: Db, begin: Instant, rpc: &Rpc, msg: Message, client: &mut WebSocket) -> Result {
+ match rpc.receive(msg, begin, &db, client) {
Ok(reply) => {
let response = to_vec(&reply)
.expect("failed to serialize response");
@@ -62,18 +60,18 @@ pub fn db_connection(url: String) -> Pool {
.expect("Failed to create pool.")
}
-fn print_panic_payload(ctx: &str, payload: &(Any + Send + 'static)) {
- let d = format!("{:?}", payload);
- let s = if let Some(s) = payload.downcast_ref::() {
- &s
- } else if let Some(s) = payload.downcast_ref::<&str>() {
- s
- } else {
- // "PAYLOAD IS NOT A STRING"
- d.as_str()
- };
- info!("{}: PANIC OCCURRED: {}", ctx, s);
-}
+// fn print_panic_payload(ctx: &str, payload: &(Any + Send + 'static)) {
+// let d = format!("{:?}", payload);
+// let s = if let Some(s) = payload.downcast_ref::() {
+// &s
+// } else if let Some(s) = payload.downcast_ref::<&str>() {
+// s
+// } else {
+// // "PAYLOAD IS NOT A STRING"
+// d.as_str()
+// };
+// info!("{}: PANIC OCCURRED: {}", ctx, s);
+// }
pub fn start() {
// panic::set_hook(Box::new(|panic_info| {
@@ -120,13 +118,8 @@ pub fn start() {
Ok(msg) => {
let begin = Instant::now();
let db_connection = db.get().expect("unable to get db connection");
- match receive(db_connection, &rpc, msg, &mut websocket) {
- Ok(method) => {
- match method.as_ref() {
- "pong" => (),
- _ => info!("response sent. total duration: {:?}", begin.elapsed()),
- }
- },
+ match receive(db_connection, begin, &rpc, msg, &mut websocket) {
+ Ok(_) => (),
Err(e) => warn!("{:?}", e),
}
},
diff --git a/server/src/rpc.rs b/server/src/rpc.rs
index 78756910..0d7f0ad1 100644
--- a/server/src/rpc.rs
+++ b/server/src/rpc.rs
@@ -6,6 +6,7 @@ use std::net::{TcpStream};
// demo
use std::iter;
+use std::time::Instant;
use rand::{thread_rng, Rng};
use rand::distributions::{Alphanumeric};
@@ -28,7 +29,7 @@ use item::{Item, ItemInfoCtr, item_info};
pub struct Rpc;
impl Rpc {
- pub fn receive(&self, msg: Message, db: &Db, client: &mut WebSocket) -> Result {
+ pub fn receive(&self, msg: Message, begin: Instant, db: &Db, client: &mut WebSocket) -> Result {
// consume the ws data into bytes
let data = msg.into_data();
@@ -51,8 +52,6 @@ impl Rpc {
None => "none".to_string(),
};
- info!("method={:?} account={:?}", v.method, account_name);
-
// check the method
// if no auth required
match v.method.as_ref() {
@@ -104,6 +103,8 @@ impl Rpc {
tx.commit()?;
+ info!("method={:?} account={:?} duration={:?}", v.method, account_name, begin.elapsed());
+
return response;
},
Err(e) => {