Exemple #1
0
        private void OnGUI()
        {
            int height = 20;
            int count  = 0;

            int getHeight()
            {
                var value = height * count;

                count++;
                return(value);
            }

            GUI.Label(new Rect(0, getHeight(), 4000, height), msg);
            var label = node.CurrentMode == APNode.Mode.Idle ? "Not Connected. Mode" : (node.CurrentMode == APNode.Mode.Client ? "I am Client" : "I am Server") + " ID : " + node.ID;

            GUI.Label(new Rect(0, getHeight(), 400, height), label);
            address = GUI.TextField(new Rect(0, getHeight(), 400, height), address);

            if (GUI.Button(new Rect(0, getHeight(), 400, height), "Create"))
            {
                node.StartServer(address);
            }
            if (GUI.Button(new Rect(0, getHeight(), 400, height), "Join"))
            {
                node.Connect(address);
            }
            if (GUI.Button(new Rect(0, getHeight(), 400, height), "Leave"))
            {
                if (node.CurrentMode == APNode.Mode.Server)
                {
                    node.StopServer();
                }
                else
                {
                    node.Disconnect();
                }
            }

            textInput = GUI.TextField(new Rect(0, getHeight(), 400, height), textInput);

            if (GUI.Button(new Rect(0, getHeight(), 400, height), "Send Message"))
            {
                node.SendPacket(node.Peers, new Packet().WithTag(textInput), true);
                textInput = "";
            }

            if (GUI.Button(new Rect(0, getHeight(), 400, height), "Print Peers"))
            {
                var str = "PEERS : [";
                foreach (var p in node.Peers)
                {
                    str += p + "  ";
                }
                str += "]";
                msg  = (str);
            }
        }
 public void HostChatroom(string chatroomName) =>
 node.StartServer(chatroomName);
Exemple #3
0
 public void StartServer() => node.StartServer(inputField.text);