Support for Separated Read Write

This commit is contained in:
Sagar Muchhal 2014-12-03 21:14:03 -05:00 committed by Josh Matthews
parent ad9aedac77
commit 75ffda9fb8
3 changed files with 18 additions and 3 deletions

View file

@ -7,6 +7,7 @@
/// Supports dynamic attaching and detaching which control notifications of navigation, etc.
use actor::{Actor, ActorRegistry};
use actors::console::ConsoleActor;
use protocol::JsonPacketStream;
use serialize::json;
@ -74,7 +75,7 @@ impl Actor for TabActor {
}
fn handle_message(&self,
_registry: &ActorRegistry,
registry: &ActorRegistry,
msg_type: &String,
_msg: &json::JsonObject,
stream: &mut TcpStream) -> bool {
@ -95,15 +96,21 @@ impl Actor for TabActor {
javascriptEnabled: true,
traits: TabTraits,
};
let console_actor = registry.find::<ConsoleActor>(self.console.as_slice());
console_actor.streams.borrow_mut().push(stream.clone());
stream.write_json_packet(&msg);
true
}
//FIXME: The current implementation won't work for multiple connections. Need to ensure 105
// that the correct stream is removed.
"detach" => {
let msg = TabDetachedReply {
from: self.name(),
__type__: "detached".to_string(),
};
let console_actor = registry.find::<ConsoleActor>(self.console.as_slice());
console_actor.streams.borrow_mut().pop();
stream.write_json_packet(&msg);
true
}