// GenerateRoomList - Generates the list of available rooms to play in. void GenerateRoomList() { for (int i = 0; i < roomList.childCount; i++) { Destroy(roomList.GetChild(i).gameObject); } // Generate UI buttons for each room. if (hostList != null) { for (int i = 0; i < hostList.Length; i++) { // Creates a button and sets up its appearance. GameObject button = (GameObject)Instantiate(roomButtonPrefab); Text[] textParts = button.GetComponentsInChildren <Text>(); textParts[0].text = hostList[i].gameName; textParts[1].text = hostList[i].connectedPlayers + " online"; textParts[2].text = hostList[i].comment; // Adds button functionality and puts it in the list. HostData host = hostList[i]; button.GetComponent <Button>().onClick.AddListener(() => { JoinServer(host); }); button.transform.SetParent(roomList); } } }
public Server(HostData data) { this.name = data.gameName; this.ip = data.ip[0]; this.port = data.port; this.guid = data.guid; this.players = data.connectedPlayers; this.max = data.playerLimit; this.ping = 0; this.reference = -1; if (this.max < 1) { this.max = 1; } else if (this.max > 12) { this.max = 12; } string[] strArrays = Packer.unpack(data.comment, ';'); this.pvp = strArrays[0] == "t"; this.mode = int.Parse(strArrays[1]); this.dedicated = strArrays[2] == "t"; this.save = strArrays[3] == "t"; this.map = int.Parse(strArrays[4]); this.version = strArrays[5]; this.passworded = strArrays[6] == "t"; this.pinger = new Ping(this.ip); }
public void GotoMain() { requestedHost = null; DisplayMenu(Menu.main); netManager.LeaveServer(); }
public void HostDataConnect(HostData hData, string password, bool doRetryConnection, VoidDelegate failDelegate) { StartedConnecting(); lastConnectHostData = hData; lastConnectUsedNAT = lastConnectHostData.useNat; lastConnectMayRetry = doRetryConnection; if (password == "") { Network.Connect(hData); } else { Network.Connect(hData, password); } Invoke("ConnectTimeout", connectTimeoutValue); lastConnectIP = hData.ip; lastConnectPort = hData.port; lastConnectPW = password; lastConnectStarted = Time.time; if (failDelegate != null) { lastConnectionFailDelegate = failDelegate; } connecting = true; }
/// <summary> /// Get Room List /// </summary> public void GetRoomList() { LO_GameServer.DefaultServer.StartRequestRoom((HostData[] dataList) => { NGUITools.DestroyChildren(room_grid.transform); foreach (HostData item in dataList) { HostData temp = item; GameObject room = NGUITools.AddChild(room_grid.gameObject, room_item); room.name = item.gameName; UILabel[] labels = room.GetComponentsInChildren <UILabel>(); labels[0].text = item.gameName; labels[1].text = item.connectedPlayers.ToString(); labels[1].text += " / " + item.playerLimit.ToString(); UIButton button = room.GetComponentInChildren <UIButton>(); button.onClick.Add(new EventDelegate(() => { LO_GameServer.DefaultServer.JoinHostRoom(temp, (int state) => { Debug.Log(state.ToString()); }); })); if (item.connectedPlayers > 2) { button.isEnabled = false; } room_grid.enabled = true; } }); }
void PlayerHitJoin(HostData hostData) { if (!joining) { Join(hostData); } }
private void PageJoin() { HostData[] rooms = MasterServer.PollHostList(); this._rooms_scroll_pos = GUILayout.BeginScrollView(this._rooms_scroll_pos); foreach (HostData room in rooms) { bool selected = this._selected_room != null ? room.guid == this._selected_room.guid : false; if (GUILayout.Toggle(selected, room.gameName + " @" + String.Format("{0}", room.ip) + ":" + room.port + " (" + room.connectedPlayers + "/" + room.playerLimit + " players)", GUI.skin.button)) { this._selected_room = room; } } GUILayout.EndScrollView(); switch (this._state) { case State.Idle: if (this._selected_room == null) { GUILayout.Label(rooms.Length > 0 ? "Select a game to join." : "No game currently running", GUILayout.Width(490)); } else if (GUILayout.Button("Join " + this._selected_room.gameName, GUILayout.Width(490))) { UnityEngine.Random.seed = int.Parse(this._selected_room.comment); Network.isMessageQueueRunning = false; Network.Connect(this._selected_room); this._state = State.Connecting; } break; case State.Connecting: GUILayout.Label("Connecting".PadRight((int)Time.realtimeSinceStartup % 3, '.'), GUILayout.Width(490)); break; case State.Starting: GUILayout.Label("Starting Game...", GUILayout.Width(490)); break; } }
public void JoinServer(HostData hostData) { ServerJoiner sj = this.GetComponent <ServerJoiner>(); sj.HostToJoin = hostData; sj.JoinServer(); }
void OnMasterServerEvent(MasterServerEvent msEvent) { if (msEvent == MasterServerEvent.HostListReceived) { hostList = MasterServer.PollHostList(); } if (!Network.isClient && !Network.isServer) { if (hostList != null) { foreach (Transform child in chooseSessionCanvas.transform) { Destroy(child.gameObject); } for (int i = 0; i < hostList.Length; i++) { GameObject SessionButton = Instantiate(chooseSessionButton) as GameObject; SessionButton.transform.parent = chooseSessionCanvas.transform; Debug.Log("hostList[i].gameName: " + hostList[i].gameName); SessionButton.transform.FindChild("Text").gameObject.GetComponent <Text> ().text = hostList[i].gameName; //the random name of the session is the new button Debug.Log("hostList[i].gameName: " + hostList[i].gameName); HostData tempHost = hostList[i]; SessionButton.GetComponent <Button>().onClick.AddListener(() => JoinServer(tempHost)); //fetch server's IP info on click //if (GUI.Button(new Rect(400, 100 + (110 * i), 300, 100), hostList[i].gameName)) // JoinServer(hostList[i]); Debug.Log("Got here"); } } } }
private void JoinServer(HostData hostData) { Debug.Log("Server Joined"); HostData hs = hostData; Network.Connect(hostData); }
private void Connect() { HostData host = serverButtons.First(b => b.Toggle.isOn).host; waitScreen.Enable("Connecting to server"); networkManager.ConnectedToServer += Connected; networkManager.ConnectToServer(host); }
private void DoGetNextHostData() { if (this.nextItemIndex >= MasterServer.PollHostList().Length) { this.nextItemIndex = 0; base.Fsm.Event(this.finishedEvent); return; } HostData hostData = MasterServer.PollHostList()[this.nextItemIndex]; this.index.Value = this.nextItemIndex; this.useNat.Value = hostData.useNat; this.gameType.Value = hostData.gameType; this.gameName.Value = hostData.gameName; this.connectedPlayers.Value = hostData.connectedPlayers; this.playerLimit.Value = hostData.playerLimit; this.ipAddress.Value = hostData.ip[0]; this.port.Value = hostData.port; this.passwordProtected.Value = hostData.passwordProtected; this.comment.Value = hostData.comment; this.guid.Value = hostData.guid; if (this.nextItemIndex >= MasterServer.PollHostList().Length) { base.Fsm.Event(this.finishedEvent); this.nextItemIndex = 0; return; } this.nextItemIndex++; if (this.loopEvent != null) { base.Fsm.Event(this.loopEvent); } }
public void ConnectToHost(HostData hostData) { if (Wifi) { serverManager.ConnectToHost(hostData); } }
/// <summary> /// Build current project after adding plugins /// </summary> private bool Flush() { if (System.IO.File.Exists("build.json")) { AppendText(_rm.GetString("Flush1")); } CreateBuildExtrasFile(); string mode = (_config.buildMode == 0) ? "--release" : "--debug"; string cmd = String.Format("cordova build android {0} --buildConfig=build.json", mode); // 코르도바는 빌드가 완료되면, 정상 출력 루트가 아닌 오류 쪽으로 빌드 완료 메시지를 보낸다. // 따라서, 오류 메시지를 정상인 것처럼 처리할 경우, 프로세스가 종료되지 않고 영원히 남게 된다. // TODO: // 따라서 빌드 실패 메시지에 빌드 성공 메시지를 넣어야 한다. // 다만, 이 경우 빌드 실패 시에도 빌드가 성공했다고 메시지가 뜨게 된다. // 구분할 수 있는 방법은 아직까지 없다. 리치 텍스트 박스에서 fail 글자를 추출하지 않는한 불가능하다. bool ret = false; using (HostData process = new HostData(cmd, true, "", _rm.GetString("Flush2"), _rm.GetString("Flush3"))) { Append append = AppendText; ret = process.Run(append); } return(ret); }
/// <summary> /// 프로젝트 파일을 복사합니다. /// </summary> private void CopyProjectFiles() { string srcPath = _config.settingGameFolder; string dstPath = ".\\www"; AppendText(_rm.GetString("CopyProjectFiles1")); if (System.IO.Directory.Exists(srcPath)) { // 다중 쓰레드 (기본값 : 8 쓰레드) // 원본과 동일한 트리로 유지 string robocopy = String.Format("chcp {0} | robocopy \"{1}\" \"{2}\" /MIR /E /R:1 /W:1", Encoding.UTF8.CodePage, srcPath, dstPath); using (var process = new HostData(robocopy, true, "", _rm.GetString("CopyProjectFiles2"), _rm.GetString("CopyProjectFiles3"))) { Append append = AppendText; process.Run(append); } } else { AppendText(_rm.GetString("CopyProjectFiles4")); } }
void UpdateInfo() { HostData serverInfo = MasterServer.PollHostList() [0]; serverName.GetComponent <Text>().text = serverInfo.gameName; playerCount.GetComponent <Text> ().text = serverInfo.connectedPlayers + "/" + serverInfo.playerLimit; }
private void JoinServer(HostData hostData) { #if UNITY_ANDROID AndroidJNI.CallIntMethod(); #endif Network.Connect(hostData); }
public void DirectConnect(string[] IP, int port, string password, bool doRetryConnection, VoidDelegate failDelegate) { StartedConnecting(); lastConnectMayRetry = doRetryConnection; lastConnectUsedNAT = false; if (password == "") { Network.Connect(IP, port); } else { Network.Connect(IP, port, password); } Invoke("ConnectTimeout", connectTimeoutValue); connecting = true; lastConnectHostData = null; lastConnectIP = IP; lastConnectPort = port; lastConnectPW = password; lastConnectStarted = Time.time; if (failDelegate != null) { lastConnectionFailDelegate = failDelegate; } }
void OnListItemUnselected(ComboBox.ComboItem unselectedItem) { if (selectedHost == (HostData)unselectedItem.value) { selectedHost = null; } }
private void GetHostData() { int num = MasterServer.PollHostList().Length; int value = this.hostIndex.Value; if (value < 0 || value >= num) { this.LogError("MasterServer Host index out of range!"); return; } HostData hostData = MasterServer.PollHostList()[value]; if (hostData == null) { this.LogError("MasterServer HostData could not found at index " + value); return; } this.useNat.Value = hostData.useNat; this.gameType.Value = hostData.gameType; this.gameName.Value = hostData.gameName; this.connectedPlayers.Value = hostData.connectedPlayers; this.playerLimit.Value = hostData.playerLimit; this.ipAddress.Value = hostData.ip[0]; this.port.Value = hostData.port; this.passwordProtected.Value = hostData.passwordProtected; this.comment.Value = hostData.comment; this.guid.Value = hostData.guid; }
/// <summary> /// 미사용 리소스를 제거하는 옵션입니다. /// </summary> public void ExcludeUnusedFiles() { string src = _config.settingGameFolder; src = src.Replace(@"\", "/"); string myDocumentsPath = DataManager.Instance.GetRootDirectory(); string dst = System.IO.Path.Combine(myDocumentsPath, _config.folderName, "www"); dst = dst.Replace(@"\", "/"); Dictionary <string, string> option = new Dictionary <string, string>(); Append append = AppendText; option["--audioFileFormat="] = DataMan.Instance.AudioFileFormat; option["--remainTree="] = DataMan.Instance.RemainTree ? "true" : "false"; StringBuilder sb = new StringBuilder(); sb.AppendFormat("mv-resource-cleaner \"{0}\" \"{1}\"", src, dst); foreach (KeyValuePair <string, string> pair in option) { sb.AppendFormat(" {0}{1}", pair.Key, pair.Value); } System.Diagnostics.Debug.WriteLine(sb.ToString()); using (var process = new HostData(sb.ToString(), true, "", "Unused resource removal succeeded.", "Failed to remove unused resources.")) { process.Run(append); } }
public void adminConnect() { NetworkManager.ip = "-1"; string password = gamePasswordInput.GetComponent <InputField> ().text; if (password.Contains("admin-")) { password = password.Substring(6); NetworkManager.pass = password; string s = names [hostSelector2.SelectedIndex]; HostData d = ClientHostPull.HostInstance.GetData(s); NetworkManager.hostData = d; source.PlayOneShot(loginSuccess, 0.3f); Application.LoadLevel(ADMIN_SCENE_NAME); } else { //TODO RAPHAEL GIMME THAT POP UP YO! This is for missing admin password incorrectPasswordPopup.SetActive(true); } //Assuming that login is successful if we got here //But this sound doesn't finish playing before it //moves onto the next scene }
void ConnectToServer(HostData _oServer) { if (!Network.isServer) { if (!Network.isClient) { if (_oServer.connectedPlayers < _oServer.playerLimit) { Network.Connect(_oServer); } else { Debug.Log("can't connect to server the server is full"); } } else { Debug.Log("can't connect to server you are already connected to a server"); } } else { Debug.Log("can't connect to server you are already a server"); } }
private void JoinServer(HostData hostData) { //Debug.Log ("Joining server!"); //DisableAllCanvasPanels (); //MenuPlane.SetActive (false); Network.Connect(hostData); }
void GetHostData() { int _count = MasterServer.PollHostList().Length; int _index = hostIndex.Value; if (_index < 0 || _index >= _count) { LogError("MasterServer Host index out of range!"); return; } HostData _hostData = MasterServer.PollHostList()[_index]; if (_hostData == null) { LogError("MasterServer HostData could not found at index " + _index); return; } useNat.Value = _hostData.useNat; gameType.Value = _hostData.gameType; gameName.Value = _hostData.gameName; connectedPlayers.Value = _hostData.connectedPlayers; playerLimit.Value = _hostData.playerLimit; ipAddress.Value = _hostData.ip[0]; port.Value = _hostData.port; passwordProtected.Value = _hostData.passwordProtected; comment.Value = _hostData.comment; guid.Value = _hostData.guid; }
void ConnectServer() { if (onConnect) { return; } HostData[] datas = MasterServer.PollHostList(); LogText.AddLog("datas " + datas); if (datas.Length > 0) { LogText.AddLog("datas.Length " + datas.Length); HostData data = datas [0]; LogText.AddLog("ip:(" + data.ip + ") port(" + data.port + ")"); if (data != null) { Network.Connect(data); onConnect = true; LogText.AddLog("Connect to server!"); } } }
public void ConnectToServer(HostData hostData, string password = "") { if (hostData != null) { Network.Connect(hostData, password); } }
//The port recieved via host data is sometimes incorrect public ServerInfo(HostData data) { string[] comment = data.comment.Split(';'); if (comment.Length != 5) { Debug.LogWarning("Server '" + data.gameName + "' has the wrong number of comment arguments"); } else { Status = comment[0]; if (!float.TryParse(comment[1], out VersionFloat)) { Debug.LogWarning("Failed to parse server version float for server '" + data.gameName + "'."); } VersionString = comment[2]; UseNAT = comment[3] == "useNat"; if (!int.TryParse(comment[4], out RealPort)) { Debug.LogWarning("Failed to parse real port for server '" + data.gameName + "'"); } } ping = new Ping(data.ip[0]); rawHostData = data; }
private IEnumerator QueryPHPMasterServerCR() { atOnce = true; string url = masterServerURL + "QueryMS.php?gameType=" + WWW.EscapeURL(gameType); // Debug.Log ("looking for URL " + url); WWW www = new WWW(url); yield return(www); retries = 0; while (www.error != null && retries < maxRetries) { retries++; www = new WWW(url); yield return(www); } if (www.error != null) { SendMessage("OnQueryMasterServerFailed"); } if (www.text == "") { yield break; } else if (www.text == "empty") { hostData = null; } else { string[] hosts = new string[www.text.Split(";"[0]).Length]; hosts = www.text.Split(";"[0]); hostData = new HostData[hosts.Length]; var index = 0; foreach (string host in hosts) { if (host == "") { continue; } string[] data = host.Split(","[0]); hostData[index] = new HostData(); hostData[index].ip = new string[1]; hostData[index].ip[0] = data[0]; hostData[index].port = int.Parse(data[1]); hostData[index].useNat = (data[2] == "1"); hostData[index].guid = data[3]; hostData[index].gameType = data[4]; hostData[index].gameName = data[5]; hostData[index].connectedPlayers = int.Parse(data[6]); hostData[index].playerLimit = int.Parse(data[7]); hostData[index].passwordProtected = (data[8] == "1"); hostData[index].comment = data[9]; index++; } } atOnce = false; }
/// <summary> /// Shows up the requiements information to Build Log /// </summary> /// <returns></returns> private bool Requirements() { var process = new HostData("cordova requirements", true, "", _rm.GetString("Requirements1"), _rm.GetString("Requirements2")); Append append = AppendText; return(process.Run(append)); }
public void SetChannels(ChannelInformationList channels) { if (channels != null) { HostData newData = new HostData(); foreach (ChannelInformation channelInfo in channels) { DeviceHolder device = null; if (newData.Devices.ContainsKey(channelInfo.Hostname)) device = newData.Devices[channelInfo.Hostname]; else { //Get device from old collection or create new if (data_.Devices.ContainsKey(channelInfo.Hostname)) { device = data_.Devices[channelInfo.Hostname]; data_.Devices.Remove(channelInfo.Hostname); device.Channels.Clear(); } else device = CreateDevice(channelInfo.Hostname, channelInfo.Port); //add device to new collection if (device != null) { newData.Devices.Add(channelInfo.Hostname, device); } } if (device != null) { device.Channels.Add(channelInfo); channelInfo.Online = (channelInfo.Channel <= device.CasparDevice.Channels.Count) ? device.HasValidConnection : false; } try { newData.ChannelInfos.Add(channelInfo.Label, channelInfo); } catch (Exception e) { MessageBox.Show("Det verkar finnas flera Caspar outputs med samma namn. Hoppar över en...", "Varning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } if (connected) { //disconnect from unused devices foreach (DeviceHolder device in data_.Devices.Values) { device.UpdatedMediafiles -= device_UpdatedMediafiles; device.UpdatedTemplates -= device_UpdatedTemplates; device.VaildConnectionChanged -= device_VaildConnectionChanged; device.CasparDevice.Disconnect(); } //connect to new devices foreach (DeviceHolder device in newData.Devices.Values) { if (!device.CasparDevice.IsConnected) device.CasparDevice.Connect(); } } //set new collection as current data_ = newData; SetValidConnections(); } }
public static NetworkConnectionError Connect(HostData hostData){}
/// <summary> /// Aktualisiert die zu versendenen Daten. /// </summary> protected void UpdateHostData() { Data = new HostData(); Data.ID = Guid.NewGuid(); Data.Addresses = GetIPAddress(); Data.Port = Server.EndPoint == null ? 0 : Server.EndPoint.Port; }
/// <summary> /// Initialisiert eine neue Instanz der HostFoundEventArgs unter verwendung des angegeben HostData-Objekts. /// </summary> /// <param name="newData">Die Daten des neugefundenen Hosts.</param> public HostFoundEventArgs(HostData newData) { NewData = newData; }
public static NetworkConnectionError Connect(HostData hostData, string password){}
/// <summary> /// Initialisiert eine neue Instanz der HostFoundEventArgs unter verwendung des angegeben HostData-Objekts. /// </summary> /// <param name="oldData">Die Daten des verlorenen Hosts.</param> public HostLostEventArgs(HostData oldData) { this.OldData = oldData; }