//..............................................................................
//
// Ninja document model - sessions
//

import "doc_Plugin.jnc"

namespace doc {

//! \addtogroup api-doc
//! @{

//..............................................................................

class Session: Plugin {
	enum SessionConnectionState {
		Disconnected,
		Connecting,
		Connected,
	}

	char const* autoget property m_title;
	SessionConnectionState autoget property m_sessionConnectionState;
	bool autoget property m_isTransmitEnabled;

	construct(PluginHost* host) {
		basetype.construct(host);
	}

	override size_t errorcode transmit(
		void const* p,
		size_t size
	) {
		return size;
	}

	virtual bool errorcode connectSession() {
		std.setError("this session doesn't know how to connect");
		return false;
	}

	virtual void disconnectSession() {}

	void startSession() {
		uint64_t timestamp = sys.getPreciseTimestamp();
		m_pluginHost.m_log.m_baseTimestamp = timestamp;
		m_logWriter.write(timestamp, log.StdRecordCode.SessionStarted);
	}

	virtual bool errorcode dispatch(
		uint_t code,
		variant in,
		variant* out = null
	) {
		std.setError("this session doesn't support IAS dispatch");
		return false;
	}
}

//..............................................................................

//! @}

} // namespace doc
