Fixed disconnect not triggering
This commit is contained in:
@@ -61,11 +61,20 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||||||
|
|
||||||
if(net.server()){
|
if(net.server()){
|
||||||
SteamConnection con = steamConnections.get(fromID);
|
SteamConnection con = steamConnections.get(fromID);
|
||||||
if(con != null){
|
//accept users on request
|
||||||
net.handleServerReceived(con, output);
|
if(con == null){
|
||||||
}else{
|
con = new SteamConnection(from);
|
||||||
Log.err("Unknown user with ID: {0}", fromID);
|
Connect c = new Connect();
|
||||||
|
c.addressTCP = "steam:" + from.getAccountID();
|
||||||
|
|
||||||
|
Log.info("&bRecieved connection: {0}", c.addressTCP);
|
||||||
|
|
||||||
|
steamConnections.put(from.getAccountID(), con);
|
||||||
|
connections.add(con);
|
||||||
|
net.handleServerReceived(con, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net.handleServerReceived(con, output);
|
||||||
}else if(currentServer != null && fromID == currentServer.getAccountID()){
|
}else if(currentServer != null && fromID == currentServer.getAccountID()){
|
||||||
net.handleClientReceived(output);
|
net.handleClientReceived(output);
|
||||||
}
|
}
|
||||||
@@ -250,10 +259,10 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||||||
Log.info("lobby {0}: {1} caused {2}'s change: {3}", lobby.getAccountID(), who.getAccountID(), changer.getAccountID(), change);
|
Log.info("lobby {0}: {1} caused {2}'s change: {3}", lobby.getAccountID(), who.getAccountID(), changer.getAccountID(), change);
|
||||||
if(change == ChatMemberStateChange.Disconnected || change == ChatMemberStateChange.Left){
|
if(change == ChatMemberStateChange.Disconnected || change == ChatMemberStateChange.Left){
|
||||||
if(net.client()){
|
if(net.client()){
|
||||||
Log.info("Current host left.");
|
|
||||||
//host left, leave as well
|
//host left, leave as well
|
||||||
if(who == currentServer){
|
if(who == currentServer || who == currentLobby){
|
||||||
net.disconnect();
|
net.disconnect();
|
||||||
|
Log.info("Current host left.");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//a client left
|
//a client left
|
||||||
@@ -354,25 +363,12 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||||||
public void onP2PSessionRequest(SteamID steamIDRemote){
|
public void onP2PSessionRequest(SteamID steamIDRemote){
|
||||||
Log.info("Connection request: {0}", steamIDRemote.getAccountID());
|
Log.info("Connection request: {0}", steamIDRemote.getAccountID());
|
||||||
if(currentServer != null && !net.server()){
|
if(currentServer != null && !net.server()){
|
||||||
Log.info("Am client");
|
Log.info("Am client, accepting request");
|
||||||
if(steamIDRemote == currentServer){
|
if(steamIDRemote == currentServer){
|
||||||
snet.acceptP2PSessionWithUser(steamIDRemote);
|
snet.acceptP2PSessionWithUser(steamIDRemote);
|
||||||
}
|
}
|
||||||
}else if(net.server()){
|
}else if(net.server()){
|
||||||
Log.info("Am server, accepting request.");
|
Log.info("Am server, accepting request from " + steamIDRemote.getAccountID());
|
||||||
//accept users on request
|
|
||||||
if(!steamConnections.containsKey(steamIDRemote.getAccountID())){
|
|
||||||
SteamConnection con = new SteamConnection(steamIDRemote);
|
|
||||||
Connect c = new Connect();
|
|
||||||
c.addressTCP = "steam:" + steamIDRemote.getAccountID();
|
|
||||||
|
|
||||||
Log.info("&bRecieved connection: {0}", c.addressTCP);
|
|
||||||
|
|
||||||
steamConnections.put(steamIDRemote.getAccountID(), con);
|
|
||||||
connections.add(con);
|
|
||||||
net.handleServerReceived(con, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
snet.acceptP2PSessionWithUser(steamIDRemote);
|
snet.acceptP2PSessionWithUser(steamIDRemote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user