public virtual void Initialize() { //this.logLevel = LogFilter.FilterLevel.Developer; if (this._networkdDiscovery == null) { this._networkdDiscovery = this.GetComponent <UnetHighLevelNetworkDiscovery>(); if (this._networkdDiscovery == null) { this._networkdDiscovery = this.gameObject.AddComponent <UnetHighLevelNetworkDiscovery>(); } string appKey = Application.companyName + "|" + Application.productName; this._networkdDiscovery.broadcastData = UFE.config.networkOptions.port.ToString(); this._networkdDiscovery.broadcastInterval = Mathf.RoundToInt(UFE.config.networkOptions.lanDiscoveryBroadcastInterval * 1000f); this._networkdDiscovery.broadcastKey = Mathf.Abs(appKey.GetHashCode()); this._networkdDiscovery.broadcastPort = UFE.config.networkOptions.lanDiscoveryPort; this._networkdDiscovery.broadcastVersion = Mathf.Abs(Application.version.GetHashCode()); this._networkdDiscovery.showGUI = false; this._networkdDiscovery.useNetworkManager = false; //this._networkdDiscovery.OnLanGamesDiscovered += this.RaiseOnLanGamesDiscovered; //this._networkdDiscovery.OnLanGamesDiscoveryError += this.RaiseOnLanGamesDiscoveryError; this._networkdDiscovery.Initialize(); } //this.StartMatchMaker (); //this.matchMaker.baseUri = new System.Uri ("https://ap1-mm.unet.unity3d.com"); Transform matchObjectTransform = this.transform.Find("networkMatch"); if (matchObjectTransform != null) { GameObject.Destroy(matchObjectTransform.gameObject); } GameObject matchObject = new GameObject(); matchObject.name = "networkMatch"; matchObject.transform.SetParent(this.transform); matchObject.AddComponent <NetworkMatch> (); this._networkMatch = matchObject.GetComponent <NetworkMatch> (); this._networkMatch.baseUri = new System.Uri("https://ap1-mm.unet.unity3d.com"); this.maxDelay = 0; this._lanDiscoveryStartSearchTime = 0f; this._lanDiscoveryLastSearchTime = 0f; this._searching = false; }
protected virtual ReadOnlyCollection <string> ParseNetworkDiscoveryResponse(Dictionary <string, NetworkBroadcastResult> response) { List <string> addresses = new List <string>(); if (response != null) { foreach (NetworkBroadcastResult result in response.Values) { addresses.Add( result.serverAddress.Replace("::ffff:", string.Empty) + ":" + UnetHighLevelNetworkDiscovery.Translate(result.broadcastData) ); } } return(new ReadOnlyCollection <string>(addresses)); }