-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from averagebrine/main
- Loading branch information
Showing
4 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,64 @@ | ||
class_name IncomingData | ||
|
||
|
||
var _data: Dictionary | ||
|
||
func _init(data: Dictionary): | ||
|
||
func _init(data: Dictionary) -> void: | ||
_data = data | ||
|
||
|
||
func get_full_data() -> Dictionary: | ||
return _data.duplicate(true) | ||
|
||
|
||
func get_string(name: String, default: String = "") -> String: | ||
var value = _data.get(name, default) | ||
if typeof(value) != TYPE_STRING: | ||
if value is not String: | ||
value = default | ||
|
||
return value | ||
|
||
|
||
func get_number(name: String, default: float = 0.0) -> float: | ||
return get_float(name, default) | ||
|
||
|
||
func get_object(name: String, default: Dictionary = {}) -> IncomingData: | ||
var value = _data.get(name, {}) | ||
if typeof(value) != TYPE_DICTIONARY: | ||
var value = _data.get(name, default) | ||
if value is not Dictionary: | ||
value = default | ||
|
||
return IncomingData.new(value) | ||
|
||
|
||
func get_array(name: String, default: Array) -> Array: | ||
var value = _data.get(name, default) | ||
if value is not Array: | ||
value = default | ||
|
||
return value | ||
|
||
|
||
func get_boolean(name: String, default: bool = false) -> bool: | ||
var value = _data.get(name, default) | ||
if value is not bool: | ||
value = default | ||
|
||
return value | ||
|
||
|
||
func get_int(name: String, default: int = 0) -> int: | ||
var value = _data.get(name, default) | ||
if value is not int and value is not float: | ||
value = default | ||
|
||
return int(value) | ||
|
||
|
||
func get_float(name: String, default: float = 0.0) -> float: | ||
var value = _data.get(name, default) | ||
if value is not int and value is not float: | ||
value = default | ||
|
||
return float(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
class_name OutgoingMessage | ||
|
||
|
||
func _get_command() -> String: | ||
push_error("OutgoingMessage._get_command() is not implemented.") | ||
return "invalid" | ||
|
||
# Returns Dictionary | null | ||
func _get_data(): | ||
return null | ||
|
||
func _get_data() -> Dictionary: | ||
return {} | ||
|
||
|
||
func merge(_other: OutgoingMessage) -> bool: | ||
return false | ||
|
||
|
||
func get_ws_message() -> WsMessage: | ||
return WsMessage.new(_get_command(), _get_data(), NeuroSdkConfig.game) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters