﻿using UnityEngine;
using System.Collections;
 
public class Connector : MonoBehaviour {
    /// <summary>
    /// server port.
    /// </summary>
    public int connectionPort = 25000;
    
    void OnGUI()
    {
        if (uLink.Network.peerType == uLink.NetworkPeerType.Disconnected)
        {
            /*initialize the server*/
			if (GUI.Button(new Rect(Screen.width-130, Screen.height-30, 120, 20), "Initialize Server"))
            {
                uLink.Network.InitializeServer(32, connectionPort, false);
				Debug.Log("Server IP: "+Network.player.ipAddress);
            }
        }
   
        else if (uLink.Network.peerType == uLink.NetworkPeerType.Server)
        {
			/*disconnect the server*/
			GUI.Label(new Rect(Screen.width-130, Screen.height-70, 300, 20), "Server IP:");
			GUI.Box(new Rect(Screen.width-130, Screen.height-50, 120, 20), Network.player.ipAddress);
			if (GUI.Button(new Rect(Screen.width-130, Screen.height-30, 120, 20), "Disconnect"))
            {

                uLink.Network.Disconnect(200);
            }
        }
    }
	
	
}