public void ConnectToIP(string ipAddress) { string http = "http://"; string port = ":5000/"; string host = http + ipAddress + port; m_sockjs.Connect(host); }
public void OnGUI() { GUI.skin = skin; if (sockjs.State == SockjsClient.ConnectionState.Disconnected) { if (GUI.Button(new Rect(0, 0, 100, 60), "connect")) { sockjs.Connect(host); } m_username = GUI.TextField(new Rect(100, 0, 200, 60), m_username); } else if (sockjs.State == SockjsClient.ConnectionState.Connecting) { GUI.Label(new Rect(10, 10, 400, 100), "connecting to: " + sockjs.Host); } else if (sockjs.State == SockjsClient.ConnectionState.Connected) { GUI.Label(new Rect(Screen.width - 80, 0, 80, 25), "ping: " + sockjs.Ping); if (GUI.Button(new Rect(0, 0, 100, 60), "disconnect")) { SendLeaveMessage(); sockjs.Disconnect(); } if (GUI.Button(new Rect(100, 0, 100, 60), "send")) { sockjs.SendData(string.Format("<b>{0}:</b> {1}", m_username, m_input)); } m_input = GUI.TextField(new Rect(200, 00, Screen.width - (100 + 200), 60), m_input); var textAreaWidth = Screen.width; var textAreaHeight = Screen.height - 60; // scrollable textarea GUILayout.BeginArea(new Rect(0, 60, textAreaWidth, textAreaHeight)); { m_scrollPos = GUILayout.BeginScrollView(m_scrollPos, false, true, GUILayout.Width(textAreaWidth), GUILayout.Height(textAreaHeight)); { GUILayout.Box(m_chat); } GUILayout.EndScrollView(); } GUILayout.EndArea(); } }