public void Shutdown() { if (!Persistent.Instance.isNetworkActive) { return; } int Result = 0; if (!Persistent.Instance.isServer && AndrickPlugin.DidServerAcceptOurConnection(ref Result) == 1) { AndrickPlugin.DisconnectUser(); } if (AndrickPlugin.ShutdownNetwork() == 0) { Debug.Log("Shutdown is a no-go"); } else { Debug.Log("I've died inside again"); } Persistent.Instance.isNetworkActive = false; }
public void IncrementCounter() { tester.numCummies = ++count; AndrickPlugin.ToDaddy(tester); //Debug.Log(AndrickPlugin.FromDaddy().numCummies); //SendPacket }
private void GetUsernames() { StringBuilder sb = new StringBuilder(AndrickPlugin.GetMaxUserCount() * 64); AndrickPlugin.GetUsernames(sb, sb.Capacity); UserNamesText.text = sb.ToString(); }
public void OnSendClicked() { if (!Persistent.Instance.isServer) { Debug.Log(string.Format("Creating message packet. {0}: {1}", AndrickPlugin.GetUsername(), ChatMessageBox.text)); AndrickPlugin.CreateMessagePacket(string.Format("{0}: {1}", AndrickPlugin.GetUsername(), ChatMessageBox.text)); ChatMessageBox.text = ""; } }
public void Shutdown() { if (AndrickPlugin.ShutdownNetwork() == 0) { Debug.Log("Shutdown is a no-go"); } else { Debug.Log("I've died inside again"); } }
public void Update() { if (Persistent.Instance.isNetworkActive && Persistent.Instance.isServer) { AndrickPlugin.ProcessPackets(); AndrickPlugin.ExecuteEvents(); UserCountText.text = string.Format("{0} / {1}", AndrickPlugin.GetConnectedUserCount().ToString(), AndrickPlugin.GetMaxUserCount().ToString()); GetUsernames(); AndrickPlugin.SendPackets(); } }
// Update is called once per frame void Update() { counter.text = count.ToString(); if (client || server) { Debug.Log("Updatre Network"); AndrickPlugin.ProcessPackets(); AndrickPlugin.ExecuteEvents(); AndrickPlugin.SendPackets(); } }
private void OnApplicationQuit() { //if (!Persistent.Instance.isNetworkActive) return; if (AndrickPlugin.ShutdownNetwork() == 0) { Debug.Log("Shutdown is a no-go"); } else { Debug.Log("I've died inside again"); } //Shutdown(); }
public void Update() { //if (!Persistent.Instance.isServer) //{ // Debug.Log("YOOO"); // //Get list of all connected users from server. // int[] playerIDs = new int[AndrickPlugin.GetConnectedUserCount()]; // AndrickPlugin.GetConnectedUserIds(playerIDs); // // IncomingServerPlayerIDs.Clear(); // IncomingServerPlayerIDs.AddRange(playerIDs); // // LocalPlayerIDs.Clear(); // foreach (PlayerInfo Info in Persistent.Instance.ConnectedPlayers) // { // LocalPlayerIDs.Add(Info.PlayerID); // } // // for (int i = 0; i < IncomingServerPlayerIDs.Count; ++i) // { // if (!LocalPlayerIDs.Contains(IncomingServerPlayerIDs[i])) // { // PlayerInfo player = new PlayerInfo(); // player.PlayerID = playerIDs[i]; // Persistent.Instance.ConnectedPlayers.Add(player); // } // } //} if (Input.GetKeyDown(KeyCode.Return)) { OnSendClicked(); } AndrickPlugin.ProcessPackets(); AndrickPlugin.ExecuteEvents(); // string tempLog = AndrickPlugin.ReadMessageLog(); while (tempLog != null) { LobbyChatLog.AddChatItem(tempLog); tempLog = AndrickPlugin.ReadMessageLog(); } //tempLog = AndrickPlugin.FromDaddy(tempLog); AndrickPlugin.SendPackets(); }
public void StartServer() { if (AndrickPlugin.ActivateServer(5)) { server = true; testInit.SetActive(false); testServerStuff.SetActive(true); Debug.Log("Server Init Succeeded!"); console.text = "Server Init Succeeded!"; } else { Debug.Log("Server Init Failed!"); console.text = "Server Init Failed!"; } }
public void StartClient() { console.text = "Client Init Trying..."; if (AndrickPlugin.ActivateClient("192.168.1.18", "friend")) { client = true; testInit.SetActive(false); testClientStuff.SetActive(true); Debug.Log("Client Init Succeeded!"); console.text = "Client Init Succeeded!"; } else { Debug.Log("Client Init Failed!"); console.text = "Client Init Failed!"; } }
public void Start() { LobbyChatLog = GetComponent <ChatLog>(); IsGameCountdownRunning = false; if (!Persistent.Instance.isServer) { PlayerData pData = new PlayerData(); AndrickPlugin.GetPlayerData(ref pData); PlayerInfo myPlayer = new PlayerInfo(); myPlayer.PlayerID = pData.ID; myPlayer.Username = AndrickPlugin.GetUsername(); myPlayer.IsLocallyControlled = true; Persistent.Instance.ConnectedPlayers.Add(myPlayer); } }
public void OnCreateServer() { //Set necessary data that needs to be sent to the server in persistent handler //So then we can ask the server about this info in the lobby int maxUsers = 0; if (int.TryParse(maxUserInput.text.ToString(), out maxUsers)) { Persistent.Instance.isServer = true; Persistent.Instance.ServerInfo.maxUsers = maxUserInput.text; if (AndrickPlugin.ActivateServer(maxUsers)) { Persistent.Instance.isNetworkActive = true; GetSceneTracker().LoadSceneSynchronously(SceneInfoList.SERVER_CONTROL_PANEL); } else { GetSceneTracker().LoadSceneSynchronously(SceneInfoList.TITLE_MENU); } } //GetSceneTracker().LoadSceneAsync(SceneInfoList.LOADING_MENU, UnityEngine.SceneManagement.LoadSceneMode.Single, OnSceneLoaded); }
// Start is called before the first frame update void Start() { Debug.Log(AndrickPlugin.ActivateServer(5)); }
IEnumerator WaitForClientConnectingResult(ClientConnectionInfo ClientInfo) { StartCoroutine(ElipseLoader()); float WaitCounter = 0.0f; if (!AndrickPlugin.ActivateClient(ClientInfo.ipAddress, ClientInfo.username)) { Debug.Log("Failed to successfully activate the client."); GetSceneTracker().LoadSceneSynchronously(SceneInfoList.TITLE_MENU); } else { while (!AndrickPlugin.DidWeInitiallyConnectToServer()) { if (WaitCounter >= MAX_WAIT_TIME) { Debug.Log("Wait time is too long for initial connection."); GetSceneTracker().LoadSceneSynchronously(SceneInfoList.TITLE_MENU); yield return(null); } AndrickPlugin.ProcessPackets(); AndrickPlugin.ExecuteEvents(); AndrickPlugin.SendPackets(); WaitCounter += Time.deltaTime; yield return(new WaitForEndOfFrame()); } WaitCounter = 0.0f; int Result = 0; while (AndrickPlugin.DidServerAcceptOurConnection(ref Result) == 0) { if (WaitCounter >= MAX_WAIT_TIME) { Debug.Log("Wait time is too long for server authentification."); GetSceneTracker().LoadSceneSynchronously(SceneInfoList.TITLE_MENU); yield return(null); } AndrickPlugin.ProcessPackets(); AndrickPlugin.ExecuteEvents(); AndrickPlugin.SendPackets(); WaitCounter += Time.deltaTime; yield return(new WaitForEndOfFrame()); } ClientConnectionCoroutine = null; if (Result == 1) { GetSceneTracker().LoadSceneSynchronously(SceneInfoList.LOBBY); } else { GetSceneTracker().LoadSceneSynchronously(SceneInfoList.TITLE_MENU); } } IsLoading = false; yield return(null); }