public override void _Ready() { InputField = (TextEdit)GetNode("Columns/IO Column/Input Field/TextEdit"); OutputField = (TextEdit)GetNode("Columns/IO Column/Output Field/TextEdit"); PeerList = (VBoxContainer)GetNode("Columns/Information Column/PeerList Panel/Scroll Container/PeerList"); IDLabel = (Label)GetNode("Columns/Information Column/ID Panel/ID Data/ID String"); networking = Networking.Instance; networking.Connect(nameof(Networking.ConnectedToSession), this, nameof(OnMeshJoined)); networking.Connect(nameof(Networking.PeerAdded), this, nameof(OnPeerAdded)); }
/// <summary> /// Teleport to the given room with a scene name, ip address and port. /// </summary> /// <param name="scene">Scene to load</param> /// <param name="host">IP address of the host</param> /// <param name="port">Port of the host</param> public static void TeleportToRoom(string scene, string host, ushort port) { Application.LoadLevel(scene); Networking.Disconnect(); Networking.Connect(host, port, Networking.TransportationProtocolType.TCP); }
public void StartClient() { NetWorker socket = null; Networking.LanDiscovery(PORT); Networking.lanEndPointFound += (target) => { isBusyFindingLan = false; if (target == null) { Debug.Log("No server found on LAN"); return; } string ipAddress = string.Empty; ushort targetPort = PORT; ipAddress = target.Address.ToString(); targetPort = (ushort)target.Port; socket = Networking.Connect(ipAddress, targetPort, Networking.TransportationProtocolType.UDP, false, false); Networking.SetPrimarySocket(socket); }; }
public override void Connect(string ip) { Networking.Connect( ip, Port, Networking.TransportationProtocolType.UDP); }
private void FinalizeJoin(HostInfo host) { NetWorker socket = Networking.Connect(host.IpAddress, host.port, host.connectionType == "udp" ? Networking.TransportationProtocolType.UDP : Networking.TransportationProtocolType.TCP, isWinRT); if (socket.Connected) { Networking.SetPrimarySocket(socket); #if UNITY_4_6 || UNITY_4_7 Application.LoadLevel(host.sceneName); #else BeardedManStudios.Network.Unity.UnitySceneManager.LoadScene(host.sceneName); #endif } else { socket.connected += delegate() { Networking.SetPrimarySocket(socket); #if UNITY_4_6 || UNITY_4_7 Application.LoadLevel(host.sceneName); #else BeardedManStudios.Network.Unity.UnitySceneManager.LoadScene(host.sceneName); #endif }; } }
public void StartClient() { host = ipAddressInput.text; if (string.IsNullOrEmpty(host.Trim())) { Debug.Log("No ip address provided to connect to"); return; } socket = Networking.Connect(host, (ushort)port, protocolType, IsWinRT, useNatHolePunching); if (!socket.Connected) { socket.ConnectTimeout = 5000; socket.connectTimeout += ConnectTimeout; } #if !NETFX_CORE if (socket is CrossPlatformUDP) { ((CrossPlatformUDP)socket).networkLatencySimulationTime = networkLatencySimulationTime; } #endif Go(); }
private void FoundEndpoint(IPEndPoint endpoint) { isBusyFindingLan = false; Networking.lanEndPointFound -= FoundEndpoint; if (endpoint == null) { Debug.Log("No server found on LAN"); return; } string ipAddress = string.Empty; ushort targetPort = 0; #if !NETFX_CORE ipAddress = endpoint.Address.ToString(); targetPort = (ushort)endpoint.Port; #else ipAddress = endpoint.ipAddress; targetPort = (ushort)endpoint.port; #endif MainThreadManager.Run(() => { socket = Networking.Connect(ipAddress, targetPort, protocolType, IsWinRT, useNatHolePunching); Go(); }); }
// Use this for initialization void Start() { networker = new Networking(); networker.Connect("192.168.0.13", "51005"); StartCoroutine(TestData()); }
private static void Request(string host, Action <NetWorker> call) { if (Networking.Sockets != null && Networking.Sockets.ContainsKey(PORT)) { Networking.Disconnect(PORT); } NetWorker socket = Networking.Connect(host, PORT, Networking.TransportationProtocolType.UDP, standAlone: true); socket.MasterServerFlag = true; socket.AddCustomDataReadEvent(WriteCustomMapping.MASTER_SERVER_REGISTER_SERVER, null); socket.AddCustomDataReadEvent(WriteCustomMapping.MASTER_SERVER_UNREGISTER_SERVER, null); socket.AddCustomDataReadEvent(WriteCustomMapping.MASTER_SERVER_UPDATE_SERVER, null); socket.AddCustomDataReadEvent(WriteCustomMapping.MASTER_SERVER_GET_HOSTS, GetHostsRequestToClient); if (socket.Connected) { call(socket); } else { socket.connected += delegate() { call(socket); } }; }
public void StartClientLan() { #if !NETFX_CORE System.Net.IPEndPoint endpoint = Networking.LanDiscovery((ushort)port, 5000, protocolType, IsWinRT); #else IPEndPointWinRT endpoint = Networking.LanDiscovery((ushort)port, 5000, protocolType, IsWinRT); #endif if (endpoint == null) { Debug.Log("No server found on LAN"); return; } string ipAddress = string.Empty; ushort targetPort = 0; #if !NETFX_CORE ipAddress = endpoint.Address.ToString(); targetPort = (ushort)endpoint.Port; #else ipAddress = endpoint.ipAddress; targetPort = (ushort)endpoint.port; #endif socket = Networking.Connect(ipAddress, targetPort, protocolType, IsWinRT, useNatHolePunching); Go(); }
// Start is called before the first frame update void Start() { if (!networking.isConnected()) { networking.Connect(); StartCoroutine(networking.ReadMessages()); } }
public void JoinButtonClickUI() { Networking.Disconnect(); WeAreHost = false; string ip = ipField.text; Networking.Connect(ip, Port, Networking.TransportationProtocolType.UDP, true); AddListeners(); }
// Start is called before the first frame update void Start() { loginInfo.isLoggedIn = false; loginInfo.sentLogin = false; if (!networking.isConnected()) { networking.Connect(); StartCoroutine(networking.ReadMessages()); } }
private async Task Connect() { UserDialogs.Instance.ShowLoading("Connecting"); string msg = await Networking.Connect(); UserDialogs.Instance.HideLoading(); alert.Title = "Connected To"; alert.Message = msg; UserDialogs.Instance.Alert(alert); }
public async void Connect(int gameId) { LogText.Clear(); ChatText.Clear(); RefreshState(); GameId = gameId; await Network.Connect(); await Network.StartReceive(); GameId = 0; }
public void TestNetworking() { // 设置服务器 //Thread p = new Thread(Server); //p.Start(); var net = new Networking(); // 连接 net.Connect("192.168.0.13", "51005"); Assert.AreEqual(true, net.Connected); //p.Abort(); }
private void DoConnect() { string host = txtHost.Text; string user = txtUser.Text; string password = txtPassword.Text; string errorMessage = ""; if (host == "") { errorMessage = "Please enter a server address"; goto OnConnectError; } if (user == "") { errorMessage = "Please enter a username"; goto OnConnectError; } if (password == "") { errorMessage = "Please enter a password"; } OnConnectError: if (errorMessage != "") { MessageBox.Show(errorMessage, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (m_networking.Connect(host, user, password)) { btnConnect.Enabled = false; btnDisconnect.Enabled = true; btnFolderRemote.Enabled = true; toolStripStatusLabel1.Text = "Connected"; } }
private void FinalizeJoin(HostInfo host) { NetWorker socket = Networking.Connect(host.IpAddress, host.port, host.connectionType == "udp" ? Networking.TransportationProtocolType.UDP : Networking.TransportationProtocolType.TCP, isWinRT); if (socket.Connected) { Networking.SetPrimarySocket(socket); Application.LoadLevel(host.sceneName); } else { socket.connected += delegate() { Networking.SetPrimarySocket(socket); Application.LoadLevel(host.sceneName); }; } }
/// <summary> /// Teleport to the given room with a scene name, ip address and port. /// </summary> /// <param name="scene">Scene to load</param> /// <param name="host">IP address of the host</param> /// <param name="port">Port of the host</param> public static void TeleportToRoom(string scene, string host, ushort port) { BeardedManStudios.Network.Unity.UnitySceneManager.LoadScene(scene); Networking.Disconnect(); Networking.Connect(host, port, Networking.TransportationProtocolType.TCP); }
public void TCPLocal() { socket = Networking.Connect("127.0.0.1", (ushort)port, protocolType, IsWinRT, useNatHolePunching); Go(); }
public void JoinServer(string ip) { Networking.Connect(ip, PORT, Networking.TransportationProtocolType.UDP); }
public void StartClient() { socket = Networking.Connect(host, (ushort)port, protocolType, IsWinRT); Go(); }
public void JoinRoom(string addr) { Networking.Connect(addr); }