added disconnect information to the client state listener
so that clients that care can know why they were booted, etc. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7043 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
1871d02b7d
commit
a14df8a68f
@ -50,7 +50,18 @@ public interface ClientStateListener
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the client has disconnected from the remote
|
* Called when the client has disconnected from the remote
|
||||||
* server.
|
* server. If info is null then the client shut down the
|
||||||
|
* connection normally, otherwise the info object contains
|
||||||
|
* additional information about the disconnect.
|
||||||
*/
|
*/
|
||||||
public void clientDisconnected( Client c );
|
public void clientDisconnected( Client c, DisconnectInfo info );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provided with the clientDisconnected() notification to
|
||||||
|
* include additional information about the disconnect.
|
||||||
|
*/
|
||||||
|
public class DisconnectInfo
|
||||||
|
{
|
||||||
|
public String reason;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import com.jme3.network.*;
|
import com.jme3.network.*;
|
||||||
|
import com.jme3.network.ClientStateListener.DisconnectInfo;
|
||||||
import com.jme3.network.message.ClientRegistrationMessage; //hopefully temporary
|
import com.jme3.network.message.ClientRegistrationMessage; //hopefully temporary
|
||||||
import com.jme3.network.message.DisconnectMessage; //hopefully temporary
|
import com.jme3.network.message.DisconnectMessage; //hopefully temporary
|
||||||
import com.jme3.network.kernel.Connector;
|
import com.jme3.network.kernel.Connector;
|
||||||
@ -208,7 +209,7 @@ public class DefaultClient implements Client
|
|||||||
|
|
||||||
// Wait for the threads?
|
// Wait for the threads?
|
||||||
|
|
||||||
fireDisconnected();
|
fireDisconnected(null);
|
||||||
|
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
}
|
}
|
||||||
@ -250,10 +251,10 @@ public class DefaultClient implements Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireDisconnected()
|
protected void fireDisconnected( DisconnectInfo info )
|
||||||
{
|
{
|
||||||
for( ClientStateListener l : stateListeners ) {
|
for( ClientStateListener l : stateListeners ) {
|
||||||
l.clientDisconnected( this );
|
l.clientDisconnected( this, info );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +272,9 @@ public class DefaultClient implements Client
|
|||||||
// Can't do too much else yet
|
// Can't do too much else yet
|
||||||
String reason = ((DisconnectMessage)m).getReason();
|
String reason = ((DisconnectMessage)m).getReason();
|
||||||
log.log( Level.SEVERE, "Connection terminated, reason:{0}.", reason );
|
log.log( Level.SEVERE, "Connection terminated, reason:{0}.", reason );
|
||||||
|
DisconnectInfo info = new DisconnectInfo();
|
||||||
|
info.reason = reason;
|
||||||
|
fireDisconnected(info);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user