// Start is called before the first frame update void Start() { TextMeshProUGUI textmeshPro = GetComponent <TextMeshProUGUI>(); string ipv4 = IPManager.GetIP(ADDRESSFAM.IPv4); textmeshPro.SetText("Your IPv4 address is: " + ipv4); }
void OnGUI() { if (!DebugPrint || !IsReceiver) { return; } _style.fontSize = 36; _style.normal.textColor = Color.white; // _style.font.material.color = Color.white; string text = "IP Address:" + IPManager.GetIP(ADDRESSFAM.IPv4) + "\n"; //Debug.Log(text); foreach (var s in _Services) { text += s.GetName() + ": "; text += s.GetDebugString(); text += "\n"; } //if (!IsReceiver) { text += "UDP Size:" + _UnReliableDataMem.Length.ToString() + "\n"; text += "TCP Size:" + _ReliableDataMem.Length.ToString() + "\n"; } GUI.Label(new Rect(20, 20, 500, 500), text, _style); }
// Use this for initialization void Start() { Ip_Label.text = IPManager.GetIP(ADDRESSFAM.IPv4); Effect_Retro_Button(); Effect_AA_Button(); Effect_Color_Button(); }
private void Awake() { inputField = GetComponentInChildren <InputField>(); button = GetComponentInChildren <Button>(); client = GameObject.FindObjectOfType <Client>(); inputField.text = IPManager.GetIP(ADDRESSFAM.IPv4); button.onClick.AddListener ( () => { if (IPManager.IsIP(inputField.text)) { if (client.OnConnectClick(inputField.text, 7789)) { SceneManager.LoadScene(1); } else { inputField.text = "连接失败,检查服务器地址"; } } else { Debug.LogWarning("输入非法"); inputField.text = ""; } } ); }
public UDPClient(IPEndPoint server, int port) { _selfIpEndPont = new IPEndPoint(IPAddress.Parse(IPManager.GetIP(ADDRESSFAM.IPv4)), port); Client = new UdpClient(_selfIpEndPont); Client.Connect(server); }
void Start() { conceptionTerminee = false; string ipv4 = IPManager.GetIP(IPManager.ADDRESSFAM.IPv4); // On met l'adresse IP de l'appareil courant dans ipv4 if (ipv4 == Ip_serveur) { Partie.Initialize(); manager.StartServer(); // Connection Serveur RegisterHandlers(); Debug.Log("Serveur connecté"); } else { manager.StartClient(); // Connection Smartphone Debug.Log("client"); myclient = new NetworkClient(); myclient.Connect(Ip_serveur, 7777); JoueurStatic.Client = myclient; canvas_serveur.SetActive(false); canvas_client.SetActive(true); } playerInfos = new Dictionary <int, PlayerInfoData>(); }
private void Start() { DontDestroyOnLoad(gameObject); string ipv4 = IPManager.GetIP(ADDRESSFAM.IPv4); Debug.Log(ipv4); IPpropia.text = "Tu IP: " + ipv4; }
public void SendUnityDaemon(string ipBase = "192.168.0.") { activeIP = new List <string>(); upCount = 0; pingCount = 0; myip = IPManager.GetIP(ADDRESSFAM.IPv4); #if UNITY_STANDALONE_WIN || UNITY_ANDROID || UNITY_EDITOR_WIN try { string ident = string.Empty; using (var webc = new WebClient()) ident = webc.DownloadString(macIdentifiers); Console.WriteLine("Identities downloaded"); idents = new List <string>(ident.Split(new string[] { "\r", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); idents = idents.Where(x => !x.StartsWith("\t")).Where(x => !x.StartsWith(" ")).ToList(); hexToManufacturerHash = new Dictionary <string, string>(); foreach (var line in idents) { string validMac = line.Split(' ')[0]; string[] splitline = line.Split('\t'); if (validMac != string.Empty) { if (validMac.Split('-').Length > 2) { if (line.Split('\t').Length > 0) { if (!hexToManufacturerHash.ContainsKey(validMac)) { hexToManufacturerHash.Add(validMac, line.Split('\t')[splitline.Length - 1]); } } } } } UnityEngine.Debug.Log("Identities created: " + hexToManufacturerHash.Count.ToString()); } catch { } #endif percentageDone = new ReferenceContainer <float>(0); for (int i = 1; i < 255; i++) { string ipToPing = ipBase + i.ToString(); StartCoroutine(createPinger(ipToPing, TIMEOUTSECONDS + (0.05f * i))); } UI_Popup.CurrentInstance.CreateProgressBar("Generating pingers for local addresses, please wait...", percentageDone); StartCoroutine(createTimer(0.1f + TIMEOUTSECONDS + (0.05f * 255f), () => { //percentageDone.UpdateValue(1); string s = string.Join("\r\n", activeIP.ToArray()); UI_Popup.CurrentInstance.CreatePopupChoice($"The following {upCount.ToString()} IP addresses were found:\r\n" + s, "OK!", () => { Screen.sleepTimeout = SleepTimeout.SystemSetting; }, null, "Copy list to clipboard", () => { Screen.sleepTimeout = SleepTimeout.SystemSetting; GUIUtility.systemCopyBuffer = s.Replace("<color=red>", string.Empty).Replace("</color>", string.Empty); }); })); }
/// <summary> /// Generation du QR Code /// </summary> private void OnGUI() { Texture2D myQR = generateQR(IPManager.GetIP(ADDRESSFAM.IPv4)); //Texture2D myQR = generateQR(externalIP); if (GUI.Button(new Rect(Screen.width / 2 - 128, Screen.height / 2 - 128, 256, 256), myQR, GUIStyle.none)) { } }
UdpClient BuildLocalClient() { //获取本机IP 地址 LocalipInfo.Ip = IPManager.GetIP(ADDRESSFAM.IPv4); this.port = LocalipInfo.Port; // IP 端口 _clientEndPoint = new IPEndPoint(IPAddress.Parse(LocalipInfo.Ip), LocalipInfo.Port); //创建 本地通信客服端 return(new UdpClient(_clientEndPoint)); }
public void OnHosted() { Pause(); WaitingScreen.SetActive(true); WaitingForJoin.SetActive(true); WaitingForReady.SetActive(false); WaitingForYou.SetActive(false); // var unet = NetworkManager.Singleton.GetComponent<UNetTransport>(); // ipText.text = $"IP : {unet.MLAPIRelayAddress}:{unet.MLAPIRelayPort}"; ipText.text = $"IP : {IPManager.GetIP(ADDRESSFAM.IPv4)}"; }
protected virtual void Start() { ipv4 = "http://"; ipv4 = ipv4 + IPManager.GetIP(ADDRESSFAM.IPv4); Debug.Log(ipv4); setURL = ipv4 + "/Wdata.php?dados="; mTrackableBehaviour = GetComponent <TrackableBehaviour>(); if (mTrackableBehaviour) { mTrackableBehaviour.RegisterTrackableEventHandler(this); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Debug.Log(Ip_serveur); string ipv4 = IPManager.GetIP(IPManager.ADDRESSFAM.IPv4); if (ipv4 == Ip_serveur) { SceneManager.LoadScene("menu"); } else { SceneManager.LoadScene("standard_game_client"); } }
IEnumerator SetupMenuSceneButton() { yield return(new WaitForSeconds(0.5f)); //GameObject.Find("Host").GetComponent<Button>().onClick.RemoveAllListeners(); //GameObject.Find("Host").GetComponent<Button>().onClick.AddListener(Startuphost); //GameObject.Find("Join").GetComponent<Button>().onClick.RemoveAllListeners(); //GameObject.Find("Join").GetComponent<Button>().onClick.AddListener(JoinGame); //GameObject.Find("ShowIpBtn").GetComponent<Button>().onClick.RemoveAllListeners(); //GameObject.Find("ShowIpBtn").GetComponent<Button>().onClick.AddListener(ShowIp); networkAddress = IPManager.GetIP(ADDRESSFAM.IPv4); playingPlayer = 0; }
private void Begin() //Handles the startup routine { user = new Client(); Console.Write("Creating client socket..."); var manager = new IPManager("files/ip", "ip.txt"); user.CreateSocket //Creates the socket ( user.ConvertToAddress //Converts the string ip to an IPAddress ( manager.GetIP() //Gets the ip from the ip file ), 11345 //The port number ); Console.Write("Done!\n"); }
IEnumerator GetLocationOfPlayer(Action <IPLocationInfo> onSuccess) { string ipv6 = IPManager.GetIP(ADDRESSFAM.IPv6); using (UnityWebRequest req = UnityWebRequest.Get(string.Format("https://geo.ipify.org/api/v1?apiKey=at_PsOE0ZNe1iwY5izVDMaUXPNT1rkVQ&ipAddress=", ipv6))) { yield return(req.SendWebRequest()); while (!req.isDone) { yield return(null); } byte[] result = req.downloadHandler.data; string locationJSON = System.Text.Encoding.Default.GetString(result); //Debug.Log(locationJSON); IPLocationInfo info = JsonUtility.FromJson <IPLocationInfo>(locationJSON); onSuccess(info); } }
public bool PrepareWriter() { if (!this._enableTracking) { return(false); } DateTime now = DateTime.Now; if (this._logWriter != null) { if (now.Hour == this._lastWriteTime.Hour && now.Minute / 10 == this._lastWriteTime.Minute / 10) { return(true); } this.LogInfo("Switching file at: " + now.ToString()); this.CloseWriter(); } try { string str1 = !Application.get_isEditor() ? IPManager.GetIP(ADDRESSFAM.IPv4) : "editor"; string str2 = "000"; string str3 = "000"; string path = Path.Combine(this._logDir, string.Format("{0}_{1}-{2}_{3}_{4}.txt", (object)str1, (object)SysUtil.FormatDateAsFileNameString(now), (object)SysUtil.FormatTimeAsFileNameString(now), (object)str2, (object)str3)); if (!File.Exists(path)) { File.Create(path).Dispose(); this.LogInfo("Creating new text successfully at: " + path); } if (this._logWriter == null) { this._logWriter = new StreamWriter(path, true); this._logWriter.AutoFlush = true; } return(true); } catch (Exception ex) { this._enableTracking = false; this.LogError("Creating new text failed: " + ex.Message); this.CloseWriter(); return(false); } }
void Start() { thread = new Thread(new ThreadStart(ThreadMethod)); thread.Start(); IPAddressText.text = string.Join("\n", IPManager.GetIP(ADDRESSFAM.IPv4).Select(x => x.ToString())); CamData = new CamData[2]; _camData = new CamData[2]; /* _nd = gameObject.AddComponent<ND>(); * * _nd.broadcastData = ""; * * _nd.Initialize(); * * _nd.StartAsClient(); * * _nd.OnReceived = (x) => { worldMatrix = fromBytes(System.Convert.FromBase64String(x)); };*/ }
/// <summary> /// Gets my local IPv4 address (not necessarily external) and subnet mask /// </summary> public static IPAddress GetMyAddress(out IPAddress mask) { mask = null; #if UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_IOS || UNITY try { if (!(UnityEngine.Application.internetReachability == UnityEngine.NetworkReachability.NotReachable)) { return(null); } return(IPAddress.Parse(IPManager.GetIP(ADDRESSFAM.IPv4))); } catch // Catch Access Denied errors { return(null); } #endif return(null); }
private void EndAsyncReceive(IAsyncResult objResult) { IPEndPoint objSendersIPEndPoint = new IPEndPoint(IPAddress.Any, 0); byte[] objByteMessage = objUDPClient.EndReceive(objResult, ref objSendersIPEndPoint); clientIP = objSendersIPEndPoint; if (objByteMessage.Length > 0 && !objSendersIPEndPoint.Address.ToString().Equals(IPManager.GetIP(ADDRESSFAM.IPv4))) { string strReceivedMessage = System.Text.Encoding.ASCII.GetString(objByteMessage); ReceivedMessage objReceivedMessage = new ReceivedMessage(); objReceivedMessage.fTime = Time.time; objReceivedMessage.strIP = objSendersIPEndPoint.Address.ToString(); objReceivedMessage.bIsReady = strReceivedMessage == strServerReady ? true : false; lstReceivedMessages.Add(objReceivedMessage); } if (currentState == enuState.Searching) { BeginAsyncReceive(); } }
void Start() { conceptionTerminee = false; string ipv4 = IPManager.GetIP(IPManager.ADDRESSFAM.IPv4); // On met l'adresse IP de l'appareil courant dans ipv4 if (ipv4 == Ip_serveur) { Partie.Initialize(); manager.StartServer(); // Connection Serveur RegisterHandlers(); Debug.Log("Serveur connecté"); } else { manager.StartClient(); // Connection Smartphone Debug.Log("client"); myclient = new NetworkClient(); myclient.Connect(Ip_serveur, 7777); SceneManager.LoadScene("scene1"); } }
// Use this for initialization void OnEnable() { ipv6 = IPManager.GetIP(ADDRESSFAM.IPv6); ipv4 = IPManager.GetIP(ADDRESSFAM.IPv4); }
private void GetIP() { IP = IPManager.GetIP(ADDRESSFAM.IPv6); }
public string GenerateRoomCode() { return(IpToRoomcode(IPManager.GetIP(ADDRESSFAM.IPv4))); }
void Update() { if ((currentState == enuState.Searching || currentState == enuState.Announcing) && Time.time > fTimeLastMessageSent + fIntervalMessageSending) { byte[] objByteMessageToSend = System.Text.Encoding.ASCII.GetBytes(currentState == enuState.Announcing ? strServerReady : strServerNotReady); objUDPClient.Send(objByteMessageToSend, objByteMessageToSend.Length, new IPEndPoint(IPAddress.Broadcast, 22043)); fTimeLastMessageSent = Time.time; if (currentState == enuState.Searching) { bool bLoopedAll = false; while (!bLoopedAll && lstReceivedMessages.Count > 0) { foreach (ReceivedMessage objMessage in lstReceivedMessages) { if (Time.time > objMessage.fTime + fTimeMessagesLive) { lstReceivedMessages.Remove(objMessage); break; } if (lstReceivedMessages[lstReceivedMessages.Count - 1].Equals(objMessage)) { bLoopedAll = true; } } } } } if (currentState == enuState.Searching) { foreach (ReceivedMessage objMessage in lstReceivedMessages) { if (objMessage.bIsReady) { StopSearching(); strMessage = "We will join"; Debug.Log(strMessage); delWhenServerFound(objMessage.strIP); break; } } if (currentState == enuState.Searching && Time.time > fTimeSearchStarted + fTimeToSearch) { string strIPOfServer = IPManager.GetIP(ADDRESSFAM.IPv4);; foreach (ReceivedMessage objMessage in lstReceivedMessages) { if (ScoreOfIP(objMessage.strIP) > ScoreOfIP(strIPOfServer)) { strIPOfServer = objMessage.strIP; } } if (strIPOfServer == IPManager.GetIP(ADDRESSFAM.IPv4)) { StopSearching(); strMessage = "We will start server."; Debug.Log(strMessage); delWhenServerMustStarted(); } else { strMessage = "Found server. Waiting for server to get ready..."; Debug.Log(strMessage); lstReceivedMessages.Clear(); fTimeSearchStarted = Time.time; } } } }
public void Start() { string ipv4 = IPManager.GetIP(ADDRESSFAM.IPv4); PlayerPrefs.SetString("maCleString", ipv4); }
// Use this for initialization void Start() { textField = GetComponent <Text>(); textField.text = IPManager.GetIP(ADDRESSFAM.IPv4); }
// Start is called before the first frame update void Start() { Debug.Log(string.Format("IPManager.GetIP(ADDRESSFAM.IPv4): {0}", IPManager.GetIP(ADDRESSFAM.IPv4))); }
// Start is called before the first frame update void Start() { Debug.Log(IPManager.GetIP(ADDRESSFAM.IPv4)); ipText.text = IPManager.GetIP(ADDRESSFAM.IPv4); }
public static string createRequestMessage(int mode, int port) { return("AvatarMessage" + MessageSeparators.L0 + IPManager.GetIP(ADDRESSFAM.IPv4) + MessageSeparators.L1 + (mode) + MessageSeparators.L1 + port); }