示例#1
0
    // Connect with local test server //
    public void StartLocalSession()
    {
        // Connect to local network
        drClient.ConnectInBackground(IPAddress.Parse("127.0.0.1"), 7777, 7777, true, delegate { OnLocalSessionCallback(); });

        // Update UI
        uiManager.SetInputInteractable(false);
    }
示例#2
0
    // Connect with local test server //
    public void StartLocalSession()
    {
        // Connect to local network
        drClient.ConnectInBackground(drClient.Host, drClient.Port, drClient.Port, true, delegate { OnLocalSessionCallback(); });

        // Update UI
        UIManager.singleton.SetInputInteractable(false);
    }
示例#3
0
    /// <summary>
    /// Connects with a given Ip address on a given port. Disables buttons until the connection times out or connects.
    /// </summary>
    /// <param name="address"> IP address of the server </param>
    /// <param name="port"> Port of the server </param>
    private async void Connect(IPAddress address, int port)
    {
        // Unfortunately a lot of code has to battle the following problem: https://github.com/DarkRiftNetworking/DarkRift/issues/81
        if (_client.ConnectionState == DarkRift.ConnectionState.Connecting)
        {
            try
            {
                _client.Disconnect();
            }
            catch (SocketException) { }
        }

        SwitchButtonsInteractable(false);
        _buttonText.text = "Connecting...";
        var tokenSource = new CancellationTokenSource();

        try
        {
            await Task.Run(() => _client.ConnectInBackground(address, port, DarkRift.IPVersion.IPv4, (Exception e) => { HandleConnectionCompleted(e); }), tokenSource.Token);
        }
        catch (ArgumentException e)
        {
            _errorText.text = "Incorrect Port Number";
            tokenSource.Cancel();
            HandleConnectionCompleted(null);
        }
    }
示例#4
0
 public void attemptConnection(string ip)
 {
     clientReference.ConnectInBackground(
         IPAddress.Parse(ip),
         4296,
         IPVersion.IPv4,
         null
         );
 }
示例#5
0
        private static void ClientConnect()
        {
            if (isClient || isConnecting)
            {
                return;
            }

            isConnecting = true;
            Main.Log("[CLIENT] Connecting to server");
            client.ConnectInBackground(host, port, true, OnConnected);
        }
示例#6
0
    void Start()
    {
        if (client == null)
        {
            client = GetComponent <UnityClient>();
        }


        client.ConnectInBackground(iP, 4296, 4297, true);

        client.MessageReceived += Client_MessageReceived;
    }
    void Awake()
    {
        if (_instance != null)
        {
            Destroy(gameObject);
            return;
        }

        _instance = this;
        DontDestroyOnLoad(this);

        Client = GetComponent <UnityClient>();
        Client.Disconnected += DisconnectCallback;
        Client.ConnectInBackground(Client.Address, Client.Port, true, ConnectCallback);
    }
示例#8
0
 // Start is called before the first frame update
 void Start()
 {
     //////////////////
     /// Load the game scene
     SceneManager.LoadScene("MainGameScene", LoadSceneMode.Additive);
     //////////////////
     /// Suscribe to events
     clientReference.MessageReceived += SpawnGameObjects;
     //////////////////
     /// Connect to the server manually
     clientReference.ConnectInBackground(
         IPAddress.Parse("127.0.0.1"),
         4296,
         DarkRift.IPVersion.IPv4,
         null
         );
 }
示例#9
0
 // Start is called before the first frame update
 void Start()
 {
     //////////////////
     /// Load the game scene
     // SceneManager.LoadScene("Game", LoadSceneMode.Additive);
     bg = BoardGenerator.instance;
     clientReference.MessageReceived += SpawnGameObjects;
     clientReference.MessageReceived += MoveChange;
     clientReference.MessageReceived += RemovePiece;
     //////////////////
     /// Connect to the server manually
     clientReference.ConnectInBackground(
         IPAddress.Parse(address),
         port,
         DarkRift.IPVersion.IPv4,
         null
         );
 }
示例#10
0
    // Start is called before the first frame update
    void Start()
    {
        /////////////////////////
        /// Load the game scene
        SceneManager.LoadScene("MainGameScene", LoadSceneMode.Additive);

        ////////////////////////
        /// Suscribe to events - 10/1 - Part 10
        /// We've added a listener on message received called SpawnGameObjects
        clientReference.MessageReceived += SpawnGameObjects;

        ///////////////////////
        /// Connect to the server manually - 10/1 - Part 10
        clientReference.ConnectInBackground        //...CONNECT IN BACKGROUND !!
        (
            IPAddress.Parse("192.168.1.104"),      //127.0.0.1         // at Tom's 10.0.0.200
            4296,
            DarkRift.IPVersion.IPv4,
            null
        );
    }
    void Start()
    {
        SceneManager.LoadScene("Game", LoadSceneMode.Additive);

        client.MessageReceived += MessageReceived;

        Debug.Log("Attempting to connect to server...");
        client.ConnectInBackground(
            client.Address,
            client.Port,
            client.IPVersion,
            e =>
        {
            if (e != null)
            {
                Debug.LogError(e);
                return;
            }

            Debug.Log("Connection successful.");
        });
    }
示例#12
0
 void Start()
 {
     Client = GetComponent <UnityClient>();
     Client.ConnectInBackground(IPAddress.Parse(ipAdress), port, IPVersion.IPv4, ConnectCallback);
 }
示例#13
0
 void Start()
 {
     Client.ConnectInBackground(IPAddress.Parse(IpAdress), Port, IPVersion.IPv4, ConnectCallback);
 }