public UTodoServerClient(Socket client, UTodoServer server) { this.client = client; this.server = server; message = new UTodoMessage(); message.clientSocket = client; client.BeginReceive(message.buffer, 0, UTodoMessage.bufferSize, SocketFlags.None, RecieveCallback, null); }
public void DrawUserPage() { using (new GUILayout.HorizontalScope()) { using (new GUILayout.VerticalScope(GUI.skin.box, GUILayout.Width(position.width / 4), GUILayout.ExpandHeight(true))) { using (new GUILayout.VerticalScope(GUI.skin.box, GUILayout.ExpandWidth(true))) { if (GUILayout.Button("登录主机")) { m_showLoginWindow = !m_showLoginWindow; } if (m_showLoginWindow) { using (new GUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Account", GUILayout.Width(60)); m_userName = EditorGUILayout.TextField(m_userName); } using (new GUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Password", GUILayout.Width(60)); m_userPassword = EditorGUILayout.PasswordField(m_userPassword); } using (new GUILayout.HorizontalScope()) { EditorGUILayout.LabelField("HostIP", GUILayout.Width(60)); m_hostIP = EditorGUILayout.TextField(m_hostIP); } GUI.color = new Color(0.5f, 1, 0.5f); if (GUILayout.Button("确定登录")) { utodoClient = new UTodoClient(); utodoClient.connect(m_hostIP, m_hostPort); } GUI.color = Color.white; } } using (new GUILayout.VerticalScope(GUI.skin.box, GUILayout.ExpandWidth(true))) { GUI.color = new Color(1, 0.3f, 0.3f); if (GUILayout.Button("申请为主机")) { // 启动Server端socket的过程,带有简单的动画 // 启动成功显示主机IP port方便其他客户端连接 utodoServer = new UTodoServer(m_hostIP, m_hostPort); m_isHost = !m_isHost; } GUI.color = Color.white; if (m_isHost) { using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(true))) { EditorGUILayout.LabelField("IP", GUILayout.Width(60)); EditorGUILayout.LabelField(m_hostIP); } using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(true))) { EditorGUILayout.LabelField("Port", GUILayout.Width(60)); EditorGUILayout.LabelField(m_hostPort.ToString()); } using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(true))) { EditorGUILayout.LabelField("Time", GUILayout.Width(60)); EditorGUILayout.LabelField(m_hostPort.ToString()); } using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(true))) { EditorGUILayout.LabelField("Online", GUILayout.Width(60)); EditorGUILayout.LabelField(utodoServer.OLCount.ToString() + "人"); } if (GUILayout.Button("关闭服务器")) { // 启动Server端socket的过程,带有简单的动画 // 启动成功显示主机IP port方便其他客户端连接 utodoServer.Close(); m_isHost = !m_isHost; } } } } using (new GUILayout.VerticalScope(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { using (new GUILayout.VerticalScope(GUI.skin.box, GUILayout.Height(position.height / 4), GUILayout.ExpandWidth(true))) { using (new GUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.ExpandWidth(true))) { EditorGUILayout.LabelField("Notifications"); } using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(true))) { using (new ScrollviewBlock(ref m_notificationsPos)) { GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); GUILayout.Label("xxx"); } } } using (new GUILayout.VerticalScope(GUI.skin.box, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true))) { using (new GUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.ExpandWidth(true))) { EditorGUILayout.LabelField("Chatroom"); } using (new GUILayout.VerticalScope(GUILayout.ExpandWidth(true))) { using (new GUILayout.VerticalScope(GUI.skin.box, GUILayout.ExpandWidth(true))) { GUILayout.Label("haha , 这事第一条消息"); GUILayoutUtility.GetRect(0, 10000, 0, 10000); } GUILayout.FlexibleSpace(); using (new GUILayout.VerticalScope(GUI.skin.box, GUILayout.Height(position.height / 10), GUILayout.ExpandWidth(true))) { using (new GUILayout.HorizontalScope(GUILayout.ExpandHeight(true))) { m_currentChatContent = GUILayout.TextArea(m_currentChatContent, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); if (GUILayout.Button("Send", GUILayout.Width(50), GUILayout.ExpandHeight(true))) { } } } } } } } }