diff options
Diffstat (limited to '')
| -rw-r--r-- | modules/websocket/websocket_peer.h (renamed from platform/javascript/power_javascript.cpp) | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/platform/javascript/power_javascript.cpp b/modules/websocket/websocket_peer.h index 5241644db..ad451e9cc 100644 --- a/platform/javascript/power_javascript.cpp +++ b/modules/websocket/websocket_peer.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* power_javascript.cpp */ +/* websocket_peer.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,47 +27,47 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#ifndef WEBSOCKETPEER_H +#define WEBSOCKETPEER_H -#include "power_javascript.h" -#include "error_macros.h" +#include "core/error_list.h" +#include "core/io/packet_peer.h" +#include "core/ring_buffer.h" +#include "websocket_macros.h" -bool PowerJavascript::UpdatePowerInfo() { - // TODO Javascript implementation - return false; -} +class WebSocketPeer : public PacketPeer { -OS::PowerState PowerJavascript::get_power_state() { - if (UpdatePowerInfo()) { - return power_state; - } else { - WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN"); - return OS::POWERSTATE_UNKNOWN; - } -} + GDCLASS(WebSocketPeer, PacketPeer); + GDCICLASS(WebSocketPeer); -int PowerJavascript::get_power_seconds_left() { - if (UpdatePowerInfo()) { - return nsecs_left; - } else { - WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); - return -1; - } -} +public: + enum WriteMode { + WRITE_MODE_TEXT, + WRITE_MODE_BINARY, + }; -int PowerJavascript::get_power_percent_left() { - if (UpdatePowerInfo()) { - return percent_left; - } else { - WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); - return -1; - } -} +protected: + static void _bind_methods(); -PowerJavascript::PowerJavascript() : - nsecs_left(-1), - percent_left(-1), - power_state(OS::POWERSTATE_UNKNOWN) { -} +public: + virtual int get_available_packet_count() const = 0; + virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) = 0; + virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) = 0; + virtual int get_max_packet_size() const = 0; -PowerJavascript::~PowerJavascript() { -} + virtual WriteMode get_write_mode() const = 0; + virtual void set_write_mode(WriteMode p_mode) = 0; + + virtual void close() = 0; + + virtual bool is_connected_to_host() const = 0; + virtual IP_Address get_connected_host() const = 0; + virtual uint16_t get_connected_port() const = 0; + virtual bool was_string_packet() const = 0; + + WebSocketPeer(); + ~WebSocketPeer(); +}; + +VARIANT_ENUM_CAST(WebSocketPeer::WriteMode); +#endif // WEBSOCKETPEER_H |
