public void InvokeOnServerJoinAccept(ClientServerInformation clientServerInformation) { if (OnServerJoinAccept != null) { OnServerJoinAccept(this, clientServerInformation); } }
public void InvokeOnServerJoinDenied(ClientServerInformation clientServerInformation) { if (OnServerJoinDenied != null) { OnServerJoinDenied(this, clientServerInformation); } }
public void InvokeOnServerDiscovered(ClientServerInformation clientServerInformation, int serverIndex) { if (OnServerDiscovered != null) { OnServerDiscovered(this, clientServerInformation, serverIndex); } }
public void InvokeServerJoin(ClientServerInformation clientServerInformation) { if (OnServerDropped != null) { OnServerDropped(this, clientServerInformation); } }
public ClientServerInformation ParseServerInformation(NetworkPackage package) { var result = new ClientServerInformation(); var keyValuePairs = ParseAdditionalDataString(package.AdditionalData); result.ServerName = keyValuePairs["name"]; result.ServerEndPoint = new UdpIpEndPoint(keyValuePairs["address"], int.Parse(keyValuePairs["port"])); result.Capacity = int.Parse(keyValuePairs["capacity"]); result.PlayerCount = int.Parse(keyValuePairs["players"]); result.UsePassword = bool.Parse(keyValuePairs["usepassword"]); return(result); }
public NetworkPackage CreatePlayerJoinRequest(ClientServerInformation server, PlayerIdentity player, String password = "") { var result = new NetworkPackage(NetworkPackageType.ClientPlayerJoinRequest); var data = new Dictionary <String, object>(); data.Add("playeridentity", player.ToString()); data.Add("playername", player.Name); // If a password is provided, add it SHA1 hashed to the package if (password != String.Empty) { data.Add("password", Plaform.HashString(password)); } result.AdditionalData = result.CreateAdditionalDataString(data); return(result); }
public void SendJoinRequest(ClientServerInformation server, PlayerIdentity playerIdentity, String password) { var package = CreatePlayerJoinRequest(server, playerIdentity, password); SendPackage(package, server.ServerEndPoint); }
public void ConnectToServer(ClientServerInformation clientServerInformation, String password = "") { ConnectedServer = clientServerInformation; SendJoinRequest(clientServerInformation, PlayerIdentity, password); ConnectionStatus = ClientStatus.Connecting; }
public void AddDiscoveredServer(ClientServerInformation clientServerInformation) { DiscoveredServers.Add(clientServerInformation); InvokeOnServerDiscovered(clientServerInformation, DiscoveredServers.Count - 1); }