Adding networking to the engine that when complet will be integrated whit the game
This commit is contained in:
parent
8f6dac310a
commit
84383f666c
17 changed files with 767 additions and 0 deletions
24
src/ei/engine/network/worker/EchoWorker.java
Normal file
24
src/ei/engine/network/worker/EchoWorker.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package ei.engine.network.worker;
|
||||
|
||||
public class EchoWorker extends Worker {
|
||||
|
||||
public void update() {
|
||||
WorkerDataEvent dataEvent;
|
||||
|
||||
while(true) {
|
||||
// Wait for data to become available
|
||||
synchronized(getEventQueue()) {
|
||||
while(getEventQueue().isEmpty()) {
|
||||
try {
|
||||
getEventQueue().wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
dataEvent = (WorkerDataEvent) getEventQueue().remove(0);
|
||||
}
|
||||
|
||||
// Return to sender
|
||||
dataEvent.network.send(dataEvent.socket, dataEvent.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue