Beispiel #1
0
 public void InvokeOnServerJoinAccept(ClientServerInformation clientServerInformation)
 {
     if (OnServerJoinAccept != null)
     {
         OnServerJoinAccept(this, clientServerInformation);
     }
 }
Beispiel #2
0
 public void InvokeOnServerJoinDenied(ClientServerInformation clientServerInformation)
 {
     if (OnServerJoinDenied != null)
     {
         OnServerJoinDenied(this, clientServerInformation);
     }
 }
Beispiel #3
0
 public void InvokeOnServerDiscovered(ClientServerInformation clientServerInformation, int serverIndex)
 {
     if (OnServerDiscovered != null)
     {
         OnServerDiscovered(this, clientServerInformation, serverIndex);
     }
 }
Beispiel #4
0
 public void InvokeServerJoin(ClientServerInformation clientServerInformation)
 {
     if (OnServerDropped != null)
     {
         OnServerDropped(this, clientServerInformation);
     }
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        public void SendJoinRequest(ClientServerInformation server, PlayerIdentity playerIdentity, String password)
        {
            var package = CreatePlayerJoinRequest(server, playerIdentity, password);

            SendPackage(package, server.ServerEndPoint);
        }
Beispiel #8
0
 public void ConnectToServer(ClientServerInformation clientServerInformation, String password = "")
 {
     ConnectedServer = clientServerInformation;
     SendJoinRequest(clientServerInformation, PlayerIdentity, password);
     ConnectionStatus = ClientStatus.Connecting;
 }
Beispiel #9
0
 public void AddDiscoveredServer(ClientServerInformation clientServerInformation)
 {
     DiscoveredServers.Add(clientServerInformation);
     InvokeOnServerDiscovered(clientServerInformation, DiscoveredServers.Count - 1);
 }