#ifndef __USE_Room_H__
#define __USE_Room_H__
#include "com_room.h"
#include "api_c/room_c.h"

class Use_Room :public Com_Room
{
public:
	Q_OBJECT
public:
	 Use_Room(QWidget *parent = 0);
	~Use_Room();
public:
	AVDHandle getHandle() const { return room_; }
protected: // c or cpp api imp
	bool   roomIsInit() const { return 0 != room_; }
	void   modulesAttach();
	Result api_joinRoom (const char* roomId, const char* userId, const char* userName, const char* userData);
	void   api_leaveRoom();
	bool   api_isWorking() const;
	Result api_enableStats(bool enable);
	rtc::NetworkStats getRoomNetStats() const;
private:
	/// room implementation
	static void s_onJoinResult(AVDHandle room, Result result);
	static void s_onLeaveIndication(AVDHandle room, Result reason, const char* fromId);
	static void s_onPublicData(AVDHandle room, const char* data, uint32 len, const char* fromId);
	static void s_onPrivateData(AVDHandle room, const char* data, uint32 len, const char* fromId);
	static void s_onAppDataNotify(AVDHandle room, const char* key, const char* value);
	static void s_onRoomStatusNotify(AVDHandle room, rtc::RoomStatus status);
	static void s_onConnectionStatus(AVDHandle room, rtc::ConnectionStatus status);
private:
	AVDHandle room_;
	Room_Callback cb_room_;
};

#endif //__USE_Room_H__
