void OnJoinLobby(JoinLobbyPackage dp) { if (dp.LobbyId != LobbyId) return; TcpClient clientToRemove = null; foreach (var v in Members) { if (dp.SenderRemoteIPEndpoint.Address.ToString() == ((IPEndPoint)v.Key.Client.RemoteEndPoint).Address.ToString()) { clientToRemove = v.Key; break; } } if (clientToRemove != null) { Members.Remove(clientToRemove); Console.WriteLine("Removed " + ((IPEndPoint)clientToRemove.Client.RemoteEndPoint).ToString() + " because joining " + dp.SenderRemoteIPEndpoint.ToString()); } Members.Add(dp.SenderTcpClient, false); ResponsePackage rp = new ResponsePackage(); rp.ResponseId = dp.Id; rp.ResponseMessage = (!freeze).ToString(); Server.Instance.Client.Write(dp.SenderTcpClient, rp); UpdateClients(); Console.WriteLine(dp.SenderRemoteIPEndpoint.ToString() + " joined lobby " + LobbyId); }
public override DataPackage CreateFromBody(string b) { JoinLobbyPackage jlp = new JoinLobbyPackage(); jlp.LobbyId = int.Parse(b); return(jlp); }
void OnJoinLobby(JoinLobbyPackage dp) { if (dp.LobbyId != LobbyId) { return; } TcpClient clientToRemove = null; foreach (var v in Members) { if (dp.SenderRemoteIPEndpoint.Address.ToString() == ((IPEndPoint)v.Key.Client.RemoteEndPoint).Address.ToString()) { clientToRemove = v.Key; break; } } if (clientToRemove != null) { Members.Remove(clientToRemove); Console.WriteLine("Removed " + ((IPEndPoint)clientToRemove.Client.RemoteEndPoint).ToString() + " because joining " + dp.SenderRemoteIPEndpoint.ToString()); } Members.Add(dp.SenderTcpClient, false); ResponsePackage rp = new ResponsePackage(); rp.ResponseId = dp.Id; rp.ResponseMessage = (!freeze).ToString(); Server.Instance.Client.Write(dp.SenderTcpClient, rp); UpdateClients(); Console.WriteLine(dp.SenderRemoteIPEndpoint.ToString() + " joined lobby " + LobbyId); }
void JoinLobby(Lobby l, Action <bool> onReceive) { WaitForResponse(JoinLobbyPackage.factory.Id, x => { bool success = false; bool.TryParse(x.ResponseMessage, out success); if (success) { currentLobby = l; } if (onReceive != null) { onReceive(success); } }); JoinLobbyPackage jlp = new JoinLobbyPackage(); jlp.LobbyId = GetLobbyId(l); c2s.WriteAll(jlp); }
void JoinLobby(Lobby l, Action<bool> onReceive) { WaitForResponse(JoinLobbyPackage.factory.Id, x => { bool success = false; bool.TryParse(x.ResponseMessage, out success); if (success) currentLobby = l; if (onReceive != null) onReceive(success); }); JoinLobbyPackage jlp = new JoinLobbyPackage(); jlp.LobbyId = GetLobbyId(l); c2s.WriteAll(jlp); }
public override DataPackage CreateFromBody(string b) { JoinLobbyPackage jlp = new JoinLobbyPackage(); jlp.LobbyId = int.Parse(b); return jlp; }