public void Connect(string ip) { ID = Guid.NewGuid().ToString(); Client = new UnityClient(); Client.Setup(ip, 6000, "pkillers"); Client.OnConnectEvent += Client_OnConnectEvent; Client.OnDisconnectEvent += Client_OnDisconnectEvent; Client.Connect(); }
public void Connect() { _client = gamecontroler.GetComponent <UnityClient>(); string ip = GetComponent <InputField>().text; System.Net.IPAddress _ip; _ip = System.Net.IPAddress.Parse(ip); int port = int.Parse(portInput.text); _client.Connect(_ip, port, DarkRift.IPVersion.IPv4); SceneManager.LoadScene("Login"); }
void Update() { Debug.Log(client.ConnectionState); if (Input.GetKeyDown("space")) { client.Connect(IPAddress.Loopback, 4296, true); } else if (Input.GetKeyDown("z")) { client.Disconnect(); } }
void Start() { Factory.Instance.CreateParent(worldCoordinates); client = UnityClient.Initialize (ipAddress, Utils.GetTestPort(), "Hololens", ThreadingType.Thread); client.Message += OnMessage; if (connect) { client.Connect(); } SendWelcomeMsgToServer(); }
public void AttemptToConnect() { if (ipAddressToConnectTo.ToLower() == "ace") { ipAddressToConnectTo = "73.131.25.197"; } else if (ipAddressToConnectTo.ToLower() == "home") { ipAddressToConnectTo = "127.0.0.1"; } UnityClient client = GameObject.Find("Network").GetComponent <UnityClient>(); System.Net.IPAddress ipAddress = System.Net.IPAddress.Parse(ipAddressToConnectTo); client.Connect(ipAddress, 4296, IPVersion.IPv4); }
/// <summary> /// Joins the local server as host without sumbiting the it's IP or port number. /// </summary> public void JoinAsHost() { IPAddress serverAddress = IPAddress.Parse("127.0.0.1"); int port = 4296; // 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) { } } _client.Connect(serverAddress, port, DarkRift.IPVersion.IPv4); }
void Start() { if (Client == null || NetworkConfig == null || Server == null) { Debug.LogError("Missing network component references, unable to initialize"); return; } if (NetworkConfig.isHost) { Server.Create(); ServerInitialized.Trigger(); } else { Client.Connect(NetworkConfig.ip, NetworkConfig.port, IPVersion.IPv4); } }
public void TTSOnConnectClick() { if (!connected) { IPAddress ip = IPAddress.Parse(ipField.text); client.Connect(ip, 4296, false); } if (client.ConnectionState == ConnectionState.Connected) { connectButton.GetComponent <Image>().color = Color.green; connectButton.GetComponentInChildren <Text>().text = "Waiting for Host..."; connected = true; } else { connected = false; } }
void Awake() { IPAddress ipAddress; if (!IPAddress.TryParse(relayIP, out ipAddress)) { ipAddress = Dns.GetHostEntry(relayIP).AddressList[0]; } drClient = GetComponent <UnityClient>(); directConnectModule = GetComponent <DarkMirrorDirectConnectModule>(); if (drClient.ConnectionState == ConnectionState.Disconnected) { drClient.Connect(IPAddress.Parse(ipAddress.ToString()), relayPort, true); } drClient.Disconnected += Client_Disconnected; drClient.MessageReceived += Client_MessageReceived; }
public void JoinServer(string ipAddress, string matchmakerTicket) { if (!client.Connected) { if (forceLocalhost) { ipAddress = "127.0.0.1"; } try { Debug.Log("DarkRift: Requesting to join server at IP address: " + ipAddress); ServerJoinUpdate?.Invoke("DarkRift: Requesting to join server at IP address: " + ipAddress); client.Connect(System.Net.IPAddress.Parse(ipAddress), client.Port, client.IPVersion); } catch (System.Exception e) { Debug.LogError("DarkRift: Connection failed to server at IP address: " + ipAddress + "\nError: " + e); ServerJoinFailure?.Invoke("DarkRift: Connection failed to server at IP address: " + ipAddress); } } if (client.Connected) { Debug.Log("DarkRift: Writing matchmaker ticket to server..."); ServerJoinUpdate?.Invoke("DarkRift: Writing matchmaker ticket to server..."); using (DarkRiftWriter writer = DarkRiftWriter.Create()) { writer.Write(matchmakerTicket); using (Message message = Message.Create(NetworkTags.Connection, writer)) { client.SendMessage(message, SendMode.Reliable); } } } else { Debug.LogError("DarkRift: Connection failed to server at IP address: " + ipAddress); ServerJoinFailure?.Invoke("DarkRift: Connection failed to server at IP address: " + ipAddress); } }
void Start() { Server.Server.ClientManager.ClientConnected += OnClientConnected; Client.Connect(IPAddress.Parse("127.0.0.1"), 4296, true); }
public async void servConnect() { await client.Connect(); }