Changeset 97 for java/main/src/main/java/com/framsticks/hosting/Server.java
- Timestamp:
- 07/06/13 03:51:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/hosting/Server.java
r96 r97 4 4 import org.apache.log4j.Logger; 5 5 6 import com.framsticks.core. Instance;6 import com.framsticks.core.Tree; 7 7 import com.framsticks.params.annotations.AutoAppendAnnotation; 8 8 import com.framsticks.params.annotations.FramsClassAnnotation; … … 17 17 import com.framsticks.util.dispatching.RunAt; 18 18 import com.framsticks.util.dispatching.Task; 19 import com.framsticks.util.dispatching.ThrowExceptionHandler; 19 20 20 21 import java.io.IOException; … … 32 33 33 34 protected ServerSocket acceptSocket; 34 protected Instance hosted;35 protected final JoinableCollection< InstanceClient> clients = new JoinableCollection<InstanceClient>();35 protected Tree hosted; 36 protected final JoinableCollection<ClientAtServer> clients = new JoinableCollection<ClientAtServer>(); 36 37 37 38 public static class Accept { … … 80 81 * @return the hosted 81 82 */ 82 public Instance getHosted() {83 public Tree getHosted() { 83 84 return hosted; 84 85 } 85 86 86 87 @AutoAppendAnnotation 87 public void setHosted( Instance hosted) {88 public void setHosted(Tree hosted) { 88 89 if (this.hosted != null) { 89 throw new FramsticksException().msg("hosted instance is already set").arg("current", this.hosted);90 throw new FramsticksException().msg("hosted tree is already set").arg("current", this.hosted); 90 91 } 91 92 this.hosted = hosted; … … 123 124 return; 124 125 } 125 acceptThread.dispatch(new RunAt<Accept>() { 126 //TODO TEH 127 acceptThread.dispatch(new RunAt<Accept>(ThrowExceptionHandler.getInstance()) { 126 128 @Override 127 p ublic void run() {129 protected void runAt() { 128 130 try { 129 131 log.debug("accepting"); … … 131 133 assert socket != null; 132 134 log.debug("accepted socket: " + socket.getInetAddress().getHostAddress()); 133 hosted.dispatch(new RunAt< Instance>() {135 hosted.dispatch(new RunAt<Tree>(this) { 134 136 @Override 135 p ublic void run() {136 InstanceClient client = new InstanceClient(Server.this, socket);137 protected void runAt() { 138 ClientAtServer client = new ClientAtServer(Server.this, socket); 137 139 clients.add(client); 138 140 log.info("client connected: " + client); … … 148 150 149 151 protected void tryBind(int when) { 150 acceptThread.dispatch(new Task<Accept>( when) {152 acceptThread.dispatch(new Task<Accept>(ThrowExceptionHandler.getInstance(), when) { 151 153 @Override 152 p ublic void run() {154 protected void runAt() { 153 155 try { 154 156 acceptSocket.bind(new InetSocketAddress(port));
Note: See TracChangeset
for help on using the changeset viewer.