pub trait Responder {
Show 21 methods
// Provided methods
fn send(&mut self, _msg: &str) { ... }
fn rec(&mut self) -> String { ... }
fn send_number(&mut self, x: usize) { ... }
fn rec_number(&mut self) -> usize { ... }
fn send_begin(&mut self) { ... }
fn send_end(&mut self) { ... }
fn send_msg(&mut self, msg: &str) { ... }
fn rec_text(&mut self) -> String { ... }
fn send_json(&mut self, jstr: &str) { ... }
fn vote(&mut self, msg: &str, list: Vec<(usize, String)>) -> (String, usize) { ... }
fn role(&self) -> Identity { ... }
fn set_role(&mut self, _r: Identity) { ... }
fn status(&self) -> LifeStatus { ... }
fn set_status(&mut self, _s: LifeStatus) { ... }
fn set_name(&mut self) { ... }
fn name(&self) -> String { ... }
fn set_id(&mut self, _id: usize) { ... }
fn get_id(&self) -> usize { ... }
fn coutinue_game(&mut self) { ... }
fn game_over(&mut self, msg: String) { ... }
fn cost(&self) -> (u64, u64) { ... }
}
Expand description
定义响应器特型。
响应器特型里实现了服务器需要的各种和玩家交互的方法。
Provided Methods§
sourcefn send_number(&mut self, x: usize)
fn send_number(&mut self, x: usize)
默认实现发送数字,开头以 n
标记。
sourcefn rec_number(&mut self) -> usize
fn rec_number(&mut self) -> usize
接收一个数字。
sourcefn send_begin(&mut self)
fn send_begin(&mut self)
表示和一个应答者通话的开始。
sourcefn vote(&mut self, msg: &str, list: Vec<(usize, String)>) -> (String, usize)
fn vote(&mut self, msg: &str, list: Vec<(usize, String)>) -> (String, usize)
投票。返回 (详情字符串, 选票指向的 id)。
注意投票需要开始信号,因为平票多次投票中,玩家只多次响应单次投票,而把详细信息当作普通信息显示。
fn role(&self) -> Identity
fn set_role(&mut self, _r: Identity)
fn status(&self) -> LifeStatus
fn set_status(&mut self, _s: LifeStatus)
fn set_name(&mut self)
fn name(&self) -> String
fn set_id(&mut self, _id: usize)
fn get_id(&self) -> usize
sourcefn coutinue_game(&mut self)
fn coutinue_game(&mut self)
在玩家端游戏结束判定时发送继续游戏。其实只是发送一个结束信号。