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

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