domain instead of ip

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

domain instead of ip

Postby Robbilie » 14 Dec 2010, 16:12

this problem existed at sfs 1x too but was fixed:

how can i use a domain insted of ip?

thanks
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 14 Dec 2010, 16:57

For now you cannot. Its on the plan to introduce this in the next release.

/Thomas
3thamthmy
Posts: 5
Joined: 11 Dec 2010, 00:54
Location: Tunisia
Contact:

Postby 3thamthmy » 14 Dec 2010, 18:17

it works for me , i used a DNS with NO-ip
am385
Posts: 3
Joined: 09 Dec 2010, 07:42

Postby am385 » 14 Dec 2010, 18:24

Yes you can. I am doing it just fine. Use a C# DNS resolver. here ill post mine.


Code: Select all




public class LoginGUI : MonoBehaviour
{

    private SmartFox smartFox;
    private string zone = "SimpleChat"; //Zone to connect to
    private string lobby = "The Lobby"; //Room to connect to

    public string serverName = "192.168.1.10"; //My local server
    public int serverPort = 9933;

    public bool useDnsResolver = true;
    public string serverDomainName = "wikked.failhub.net"; //My domain name

    private string username = "";
    private string password = "";

    private string loginErrorMessage = "";
    private bool isLoggedIn;
    private bool isJoining = false;

    public bool useUDP = true;





    public GUISkin gSkin;

    private Room currentActiveRoom;


    private Rect windowRect;


    void Awake()
    {
        Screen.showCursor = true;
        Screen.lockCursor = false;

        if (useDnsResolver)// Enable a DNS Resolver to obtain servers public IP from a domain name
        {
            IPHostEntry ip = Dns.GetHostEntry(serverDomainName);
            IPAddress[] ipA = ip.AddressList;

            if (ipA.Length > 0)
            {
                serverName = ipA[0].ToString();
            }
        }
    }





So just make sure you put that in your awake so it can try to resolve the domain into an IP before you try to connect to it. I have my login script start like that and has boolean switches inside unity to control if it uses the resolver or just an IP.

All thats really important in that code above is everything under the useDnsResolver if statement. Set the serverDomainName to your domain of choice. I just use a dynamic DNS server to redirect it all to my local routers public IP.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 14 Dec 2010, 19:03

Yeah - you can definitely for now put the code into your game.

I'm adding direct support into the api for next release. It will be a 3.0+ feature only though, because Unity pre-2.6 webplayers dont like any kind of DNS lookup (will crash on exit usually).

/Thomas
3thamthmy
Posts: 5
Joined: 11 Dec 2010, 00:54
Location: Tunisia
Contact:

Postby 3thamthmy » 15 Dec 2010, 01:37

is there any way to add a server favorit list , so when we exit from the game and turning back ,we dont need to type the server again .

like add the server to my favorites .

many thanks .
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 15 Dec 2010, 05:58

Certainly - but thats not a SFS question.

http://unity3d.com/support/documentatio ... Prefs.html
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 15 Dec 2010, 15:30

ur code gives me two errors:

one to iphostentry and one to ipadress

is there something u have that i dont have :D

robert
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 15 Dec 2010, 15:41

System.net namespace ?
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 15 Dec 2010, 18:39

ahh thanks appels xD

Im not using these integrated things so i didnt thought of them..

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 54 guests