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
35
src/ei/engine/network/response/ResponseEvent.java
Normal file
35
src/ei/engine/network/response/ResponseEvent.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package ei.engine.network.response;
|
||||
|
||||
|
||||
public abstract class ResponseEvent {
|
||||
private byte[] rsp = null;
|
||||
|
||||
public synchronized boolean handleResponse(byte[] rsp) {
|
||||
this.rsp = rsp;
|
||||
notify();
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized void waitForResponse() {
|
||||
while(!gotResponse()) {
|
||||
try {
|
||||
this.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
responseEvent(rsp);
|
||||
}
|
||||
|
||||
public void handleResponse(){
|
||||
if(gotResponse()){
|
||||
responseEvent(rsp);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean gotResponse(){
|
||||
return (rsp != null);
|
||||
}
|
||||
|
||||
protected abstract void responseEvent(byte[] rsp);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue