Ejemplo n.º 1
0
    public void ConnectToServer(string ipToUse)
    {
        if (ipToUse != "")
        {
            ip = ipToUse;
        }

        InitializeClientData();

        isConnected = true;
        tcp.Connect();
    }
Ejemplo n.º 2
0
        void Awake()
        {
            instance = this;
            DontDestroyOnLoad(this);

            lh = new Framework.Log.LogHandler();

            var config = new ServerConfig();
            var coder  = new Coder();

            TCPInstance    = new TCP(config, coder);
            UpdateActions += TCPInstance.DoActions;
            TCPInstance.Connect();

            UIInstance = new UIManager();
            var userDataInst = UserData.Instance;
            var roomInst     = Lobby.Instance;
            var battleInst   = BattleData.Instance;
            var dialogInst   = Dialog.Instance;

            Screen.sleepTimeout = SleepTimeout.NeverSleep;

            SceneManager.sceneLoaded   += SceneManager_sceneLoaded;
            SceneManager.sceneUnloaded += SceneManager_sceneUnloaded;

            AssetBundleManager.Instance.LoadManifestAsyn(m => { /*SceneManager.LoadScene(1);*/ }, () => {  });
            UIInstance.PushWindowFromResource(WindowType.Loading, WinMsg.None);
        }
Ejemplo n.º 3
0
    public void ConnectToServer()
    {
        InitializeClientData();
        UIManager.instance.InitializeErrorCodes();

        tcp.Connect();
    }
    public void ConnectToServer()
    {
        Debug.Log("connectto server");
        InitializeClientData();

        tcp.Connect();
    }
Ejemplo n.º 5
0
 private void ConsoleInput_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue == 13)
     {
         ConsoleOutputList.Add(ConsoleInput.Text);
         ConsoleOutputList.Add(TCP.Connect(Mission.IP, ConsoleInput.Text, Mission.port));
         ConsoleInput.Text = "";
         GenerateText();
         ConsoleWindow.Text = ConsoleOutput;
         remebered          = ConsoleOutputList.Count;
     }
     if (e.KeyValue == 38)
     {
         if (remebered - 2 > 0)
         {
             remebered        -= 2;
             ConsoleInput.Text = ConsoleOutputList[remebered];
         }
     }
     if (e.KeyValue == 40)
     {
         if (remebered + 2 < ConsoleOutputList.Count)
         {
             remebered        += 2;
             ConsoleInput.Text = ConsoleOutputList[remebered];
         }
         else
         {
             ConsoleInput.Text = "";
         }
     }
 }
Ejemplo n.º 6
0
    public void ConnectToServer()
    {
        InitializeClientData();

        isConnected = true;
        tcp.Connect();
    }
Ejemplo n.º 7
0
        public static void Connect(string _username, string _ip, int _port)
        {
            myUsername = _username;
            ip         = _ip;
            port       = _port;

            try
            {
                TcpClient tcpClient = new TcpClient();

                Console.WriteLine("Connecting...");

                tcpClient.Connect(_ip, _port);

                tcp = new TCP();

                InitializeClientData();

                isConnected = true;
                tcp.Connect();

                Console.WriteLine("Connected.");
            }
            catch (Exception _ex)
            {
                Console.WriteLine($"An error occured: {_ex}");
            }
        }
Ejemplo n.º 8
0
        public void Connect()
        {
            tcp = new TCP(HandlePacket, Disconnect, OnConnectInvoked, OnConnectionFailedInvoked, (int _id) => { id = _id; });

            isConnected = true;
            tcp.Connect(ip, port);
        }
Ejemplo n.º 9
0
    public void ConnectToServer(String ipaddress, int port)
    {
        InitializeClientData();

        isConnected = true;
        tcp.Connect(ipaddress, port);
    }
Ejemplo n.º 10
0
 public void ConnectToServer(string addr = IP_ADDRESS)
 {
     Debug.Log($"Calling tcp.Connect() | Socket: {addr}:{PORT}");
     InitializeClientData();
     tcp = new TCP();
     tcp.Connect(addr, PORT);
 }
Ejemplo n.º 11
0
 public void ConnectToServer(bool _createNewPersonalData)
 {
     InitializeClientData();
     isConnected           = true;
     createNewPersonalData = _createNewPersonalData;
     tcp.Connect();
 }
Ejemplo n.º 12
0
 public void ConnectToServer(bool _console)
 {
     InitializeClientData();
     isConnected = true;
     console     = _console;
     tcp.Connect();
 }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            Console.WriteLine("IP:");
            string IP = Console.ReadLine();

            Console.WriteLine("PORT:");
            int port = int.Parse(Console.ReadLine());

            Console.WriteLine("Mission Name:");
            string missionName = Console.ReadLine();
            double time        = 0;

            while (true)
            {
                List <Image> images = new List <Image>();
                images.Add(Image.FromFile(@"andrzej1.jpg"));
                images.Add(Image.FromFile(@"andrzej2.jpg"));
                images.Add(Image.FromFile(@"andrzej3.jpg"));
                images.Add(Image.FromFile(@"andrzej4.jpg"));
                images.Add(Image.FromFile(@"andrzej5.jpg"));

                foreach (var image in images)
                {
                    TCP.Connect(IP, "SendUpdate " + missionName + " Images " + time + " " + Base64.ImageToBase64(image, ImageFormat.Jpeg), port);
                    time += 0.2;
                    Thread.Sleep(5000);
                }
            }
        }
Ejemplo n.º 14
0
    //hack: e
    //private void Start()
    //{
    //    tcp = new TCP();
    //    udp = new UDP();
    //}

    public void ConnectToServer(string _ipField) //public void ConnectToServer() => tcp.Connect();
    {
        tcp = new TCP();
        udp = new UDP();

        var _ipFieldArray = Dns.GetHostAddresses(_ipField);

        foreach (var i in _ipFieldArray)
        {
            if (_ipField.Length > 0)
            {
                string[] subIP = i.ToString().Split('.');

                if (subIP.Length == 4)
                {
                    ip = i.ToString();
                    //InitializeClientData();
                    //tcp.Connect(); //TODO: fix this double connect bug - not to do with udp, i removed
                    //break; //HACK: Remove this since bit would happen anyway at the end!
                }
                else
                {
                    //TODO: IPV6
                }
            }
        }
        Debug.Log(_ipField);  //UDP doesn't connect.
        InitializeClientData();
        tcp.Connect();
    }
Ejemplo n.º 15
0
    /// <summary>Attempts to connect to the server.</summary>
    public void ConnectToServer()
    {
        InitializeClientData();

        isConnected = true;
        tcp.Connect(); // Connect tcp, udp gets connected once tcp is done
    }
Ejemplo n.º 16
0
    public void ConnectToServerManager()
    {
        UnityEngine.Debug.Log("Connecting to ServerManager");
        TcpClient tcpClient = new TcpClient(_serverManagerIP, _serverManagerPort);

        ServerManagerTCP = new TCP();
        ServerManagerTCP.Connect(tcpClient, PacketHandlers.ServerManagerClient, false);
    }
Ejemplo n.º 17
0
    public void ConnectToServer()
    {
        //Initializes the Data of the Client
        InitializeClientData();

        //Calls the Connect() method
        tcp.Connect();
    }
Ejemplo n.º 18
0
    public void ConnectToServer()
    {
        tcp = new TCP();
        udp = new UDP();

        InitializeClientData();
        tcp.Connect();
    }
Ejemplo n.º 19
0
    //클라이언트에서 사용할 때.
    public NetworkController(string serverAddress)
    {
        hostType = HostType.Client;

        GameObject nObj = GameObject.Find("Network");
        network = nObj.GetComponent<TCP>();
        network.Connect(serverAddress, PORT);
    }
Ejemplo n.º 20
0
 public void ConnectToServer(string _userName)
 {
     Username = _userName;
     tcp      = new TCP();
     udp      = new UDP(PacketHandlers.Client);
     tcp.Connect(ip, port, PacketHandlers.Client);
     GameManager.instance.SpawnPlayerUI(this);
 }
Ejemplo n.º 21
0
 public static void ConnectToServer(string ip, int port = 23000)
 {
     isConnecting = true;
     desiredIp    = (string.IsNullOrEmpty(ip))?"127.0.0.1":ip;
     tcp          = new TCP();
     udp          = new UDP();
     InitData();
     tcp.Connect(desiredIp, port);
 }
Ejemplo n.º 22
0
    public void ConnectToServer()
    {
        tcp = new TCP();

        isConnected = true;
        tcp.Connect();
        Debug.Log("Connected to server: " + tcp.socket.Client.RemoteEndPoint);
        GameSettings.activeConnection = GameSettings.Connection.Client;
    }
Ejemplo n.º 23
0
    public void ConnectToServer()
    {
        tcp = new TCP();
        udp = new UDP();        //sets up our network protocols

        InitializeClientData(); //self explanatory
        isConnected = true;
        tcp.Connect();
    }
Ejemplo n.º 24
0
        public static void initTCP()
        {
            var config = new ServerConfig();
            var coder  = new Coder();

            TCPInstance             = new TCP(config, coder);
            instance.UpdateActions += TCPInstance.DoActions;
            TCPInstance.Connect();
        }
Ejemplo n.º 25
0
        public void ConnectToServer()
        {
            tcp = tcp ?? new TCP();
            udp = udp ?? new UDP();

            InitializeClientData();
            isConnected = true;
            tcp.Connect(Instance.serverIp, Instance.port);
        }
Ejemplo n.º 26
0
        static string CommandExecute()
        {
            string respond;

            try { respond = TCP.Connect(Mission.IP, command, Mission.port); }
            catch (Exception e) { throw new UnableToConnectToServerException(); }
            clear();
            return(respond);
        }
Ejemplo n.º 27
0
 private IEnumerator LoginAttempt()
 {
     while (!isConnected)
     {
         if (connectionAttempt++ <= maxConnectionAttempts)
         {
             tcp.Connect();
             Debug.Log($"Attempting Connection: {connectionAttempt} at: {Time.time}");
             yield return(new WaitForSeconds(attemptOffset));
         }
         else
         {
             Debug.Log("Sever is not responding.");
             isConnected = true;
         }
     }
     Debug.Log($"Connection successful on attempt: {connectionAttempt}");
 }
Ejemplo n.º 28
0
    public void ConnectToServer()                                                       // Connect to server btn
    {
        tcp = new TCP();
        udp = new UDP();

        InitializeClientData();
        IsConnected = true;
        tcp.Connect();
    }
Ejemplo n.º 29
0
 public void ConnectToServer(GameserverInstance gameserverInstance)
 {
     tcp  = new TCP();
     udp  = new UDP(PacketHandlers.Client);
     ip   = gameserverInstance.IP;
     port = gameserverInstance.Port;
     tcp.Connect(ip, port, PacketHandlers.Client);
     GameManager.instance.SpawnPlayerUI(this);
 }
Ejemplo n.º 30
0
 private void Start()
 {
     tcp = new TCP();
     udp = new UDP();
     InitializeClientData();
     coroutine = LoginAttempt();
     StartCoroutine(coroutine);
     tcp.Connect();
 }
Ejemplo n.º 31
0
    /// <summary>Attempts to connect to the server.</summary>
    public void ConnectToServer()
    {
        tcp = new TCP();
        udp = new UDP();

        InitializeClientData();

        tcp.Connect(); // Connect tcp, udp gets connected once tcp is done
    }