private void GetRoomList(UserToken token, DataModel model) { RoomList list = new RoomList(); for (int i = 0; i < socketServerManager.GetRoomList().Count; i++) { string str = socketServerManager.GetRoomList()[i].RoomName + "," + socketServerManager.GetRoomList()[i].UserList.Count; list.List.Add(str); } model.Request = DataRequest.GET_ROOMLIST_S; model.Message = DataCodec.TobyteArray(list); Send(token, model); Console.WriteLine(token.UserName + "--> get roomlist:" + list.List.Count); }
/// <summary> /// 通知所有用户房间列表有更新,发送新的房间列表 /// </summary> internal void OnRoomListUpdate() { RoomList list = new RoomList(); for (int i = 0; i < socketServerManager.GetRoomList().Count; i++) { string str = socketServerManager.GetRoomList()[i].RoomName + "," + socketServerManager.GetRoomList()[i].UserList.Count; list.List.Add(str); } DataModel model = new DataModel(); model.Type = DataType.TYPE_SPORDER; model.Request = DataRequest.GET_ROOMLIST_S; model.Message = DataCodec.TobyteArray(list); for (int i = 0; i < socketServerManager.GetClientList().Count; i++) { Send(socketServerManager.GetClientList()[i], model); } }