Skip to content

Commit

Permalink
Update for Godot 3.4.4, Nakama 3.10.0 and the Godot Nakama Client v3.…
Browse files Browse the repository at this point in the history
…1.0 (#37)
  • Loading branch information
dsnopek authored Apr 28, 2022
1 parent 4d8e947 commit 3957c8c
Show file tree
Hide file tree
Showing 63 changed files with 6,436 additions and 897 deletions.
3 changes: 3 additions & 0 deletions godot/addons/com.heroiclabs.nakama/Nakama.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const DEFAULT_LOG_LEVEL = NakamaLogger.LOG_LEVEL.DEBUG
var _http_adapter = null
var logger = NakamaLogger.new()

func _ready() -> void:
Nakama.pause_mode = Node.PAUSE_MODE_PROCESS

func get_client_adapter() -> NakamaHTTPAdapter:
if _http_adapter == null:
_http_adapter = NakamaHTTPAdapter.new()
Expand Down
1,819 changes: 1,579 additions & 240 deletions godot/addons/com.heroiclabs.nakama/api/NakamaAPI.gd

Large diffs are not rendered by default.

297 changes: 291 additions & 6 deletions godot/addons/com.heroiclabs.nakama/api/NakamaRTAPI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Channel extends NakamaAsyncResult:

const _SCHEMA = {
"id": {"name": "id", "type": TYPE_STRING, "required": true},
"presences": {"name": "presences", "type": TYPE_ARRAY, "required": true, "content": "UserPresence"},
"presences": {"name": "presences", "type": TYPE_ARRAY, "required": false, "content": "UserPresence"},
"self": {"name": "self_presence", "type": "UserPresence", "required": true},
"room_name": {"name": "room_name", "type": TYPE_STRING, "required": false},
"group_id": {"name": "group_id", "type": TYPE_STRING, "required": false},
Expand Down Expand Up @@ -166,6 +166,59 @@ class ChannelPresenceEvent extends NakamaAsyncResult:
static func get_result_key() -> String:
return "channel_presence_event"


# Describes an error which occurred on the server.
class Error extends NakamaAsyncResult:

const _SCHEMA = {
"code": {"name": "code", "type": TYPE_INT, "required": true},
"message": {"name": "message", "type": TYPE_STRING, "required": true},
"context": {"name": "context", "type": TYPE_DICTIONARY, "required": false, "content": TYPE_STRING},
}

# The selection of possible error codes.
enum Code {
# An unexpected result from the server.
RUNTIME_EXCEPTION = 0,
# The server received a message which is not recognised.
UNRECOGNIZED_PAYLOAD = 1,
# A message was expected but contains no content.
MISSING_PAYLOAD = 2,
# Fields in the message have an invalid format.
BAD_INPUT = 3,
# The match id was not found.
MATCH_NOT_FOUND = 4,
# The match join was rejected.
MATCH_JOIN_REJECTED = 5,
# The runtime function does not exist on the server.
RUNTIME_FUNCTION_NOT_FOUND = 6,
#The runtime function executed with an error.
RUNTIME_FUNCTION_EXCEPTION = 7,
}

# The error code which should be one of "Error.Code" enums.
var code : int

# A message in English to help developers debug the response.
var message : String

# Additional error details which may be different for each response.
var context : Dictionary

func _init(p_ex = null).(p_ex):
pass

func _to_string():
if is_exception(): return get_exception()._to_string()
return "Error<code=%s, messages=%s, context=%s>" % [code, message, context]

static func create(p_ns : GDScript, p_dict : Dictionary) -> Error:
return _safe_ret(NakamaSerializer.deserialize(p_ns, "Error", p_dict), Error) as Error

static func get_result_key() -> String:
return "error"


# A multiplayer match.
class Match extends NakamaAsyncResult:

Expand Down Expand Up @@ -279,6 +332,7 @@ class MatchPresenceEvent extends NakamaAsyncResult:
static func get_result_key() -> String:
return "match_presence_event"


# The result of a successful matchmaker operation sent to the server.
class MatchmakerMatched extends NakamaAsyncResult:

Expand Down Expand Up @@ -350,17 +404,21 @@ class MatchmakerTicket extends NakamaAsyncResult:
class MatchmakerUser extends NakamaAsyncResult:

const _SCHEMA = {
"numeric_properties": {"name": "numeric_properties", "type": TYPE_DICTIONARY, "required": false, "content": TYPE_REAL},
"presence": {"name": "presence", "type": "UserPresence", "required": true},
"party_id": {"name": "party_id", "type": TYPE_STRING, "required": false},
"string_properties": {"name": "string_properties", "type": TYPE_DICTIONARY, "required": false, "content": TYPE_STRING},
"presence": {"name": "presence", "type": "UserPresence", "required": true}
"numeric_properties": {"name": "numeric_properties", "type": TYPE_DICTIONARY, "required": false, "content": TYPE_REAL},
}

# The numeric properties which this user asked to matchmake with.
var numeric_properties : Dictionary

# The presence of the user.
var presence : UserPresence

# Party identifier, if this user was matched as a party member.
var party_id : String

# The numeric properties which this user asked to matchmake with.
var numeric_properties : Dictionary

# The string properties which this user asked to matchmake with.
var string_properties : Dictionary

Expand Down Expand Up @@ -530,6 +588,7 @@ class StreamData extends NakamaAsyncResult:
static func get_result_key() -> String:
return "stream_data"


# An object which represents a connected user in the server.
# The server allows the same user to be connected with multiple sessions. To uniquely identify them a tuple of
# `{ node_id, user_id, session_id }` is used which is exposed as this object.
Expand Down Expand Up @@ -574,3 +633,229 @@ class UserPresence extends NakamaAsyncResult:

static func get_result_key() -> String:
return "user_presence"


class Party extends NakamaAsyncResult:

const _SCHEMA = {
"party_id": {"name": "party_id", "type": TYPE_STRING, "required": true},
"open": {"name": "open", "type": TYPE_BOOL, "required": false},
"max_size": {"name": "max_size", "type": TYPE_INT, "required": true},
"self": {"name": "self_presence", "type": "UserPresence", "required": true},
"leader": {"name": "leader", "type": "UserPresence", "required": true},
"presences": {"name": "presences", "type": TYPE_ARRAY, "required": false, "content": "UserPresence"},
}

# Unique party identifier.
var party_id : String

# Open flag.
var open : bool = false

# Maximum number of party members.
var max_size : int

# The presence of the current user. i.e. Your self.
var self_presence : NakamaRTAPI.UserPresence

# Leader.
var leader : NakamaRTAPI.UserPresence

# All current party members.
var presences : Array # of objects NakamaUserPresence

func _init(p_ex = null).(p_ex):
pass

func serialize() -> Dictionary:
return NakamaSerializer.serialize(self)

func _to_string():
if is_exception(): return get_exception()._to_string()
return "Party<party_id=%s, open=%s, max_size=%d, self=%s, leader=%s, presences=%s>" % [
party_id, open, max_size, self_presence, leader, presences]

static func create(p_ns : GDScript, p_dict : Dictionary) -> Party:
return _safe_ret(NakamaSerializer.deserialize(p_ns, "Party", p_dict), Party) as Party

static func get_result_key() -> String:
return "party"


# Presence update for a particular party.
class PartyPresenceEvent extends NakamaAsyncResult:
const _SCHEMA = {
"party_id": {"name": "party_id", "type": TYPE_STRING, "required": true},
"joins": {"name": "joins", "type": TYPE_ARRAY, "required": false, "content": "UserPresence"},
"leaves": {"name": "leaves", "type": TYPE_ARRAY, "required": false, "content": "UserPresence"},
}
# The party ID.
var party_id : String
# User presences that have just joined the party.
var joins : Array
# User presences that have just left the party.
var leaves : Array

func _init(p_ex = null).(p_ex):
pass

func serialize() -> Dictionary:
return NakamaSerializer.serialize(self)

func _to_string():
if is_exception(): return get_exception()._to_string()
return "PartyPresenceEvent<party_id=%s, joins=%s, leaves=%s>" % [party_id, joins, leaves]

static func create(p_ns : GDScript, p_dict : Dictionary) -> PartyPresenceEvent:
return _safe_ret(NakamaSerializer.deserialize(p_ns, "PartyPresenceEvent", p_dict), PartyPresenceEvent) as PartyPresenceEvent

static func get_result_key() -> String:
return "party_presence_event"


# Announcement of a new party leader.
class PartyLeader extends NakamaAsyncResult:
const _SCHEMA = {
"party_id": {"name": "party_id", "type": TYPE_STRING, "required": true},
"presence": {"name": "presence", "type": "UserPresence", "required": true},
}
# Party ID to promote a new leader for.
var party_id : String
# The presence of an existing party member to promote as the new leader.
var presence : NakamaRTAPI.UserPresence

func _init(p_ex = null).(p_ex):
pass

func serialize() -> Dictionary:
return NakamaSerializer.serialize(self)

func _to_string():
if is_exception(): return get_exception()._to_string()
return "PartyLeader<party_id=%s, presence=%s>" % [party_id, presence]

static func create(p_ns : GDScript, p_dict : Dictionary) -> PartyLeader:
return _safe_ret(NakamaSerializer.deserialize(p_ns, "PartyLeader", p_dict), PartyLeader) as PartyLeader

static func get_result_key() -> String:
return "party_leader"


# Incoming notification for one or more new presences attempting to join the party.
class PartyJoinRequest extends NakamaAsyncResult:
const _SCHEMA = {
"party_id": {"name": "party_id", "type": TYPE_STRING, "required": true},
"presences": {"name": "presences", "type": TYPE_ARRAY, "required": false, "content": "UserPresence"},
}
# Party ID these presences are attempting to join.
var party_id : String
# Presences attempting to join.
var presences : Array

func _init(p_ex = null).(p_ex):
pass

func serialize() -> Dictionary:
return NakamaSerializer.serialize(self)

func _to_string():
if is_exception(): return get_exception()._to_string()
return "PartyJoinRequest<party_id=%s, presences=%s>" % [party_id, presences]

static func create(p_ns : GDScript, p_dict : Dictionary) -> PartyJoinRequest:
return _safe_ret(NakamaSerializer.deserialize(p_ns, "PartyJoinRequest", p_dict), PartyJoinRequest) as PartyJoinRequest

static func get_result_key() -> String:
return "party_join_request"


# A response from starting a new party matchmaking process.
class PartyMatchmakerTicket extends NakamaAsyncResult:
const _SCHEMA = {
"party_id": {"name": "party_id", "type": TYPE_STRING, "required": true},
"ticket": {"name": "ticket", "type": TYPE_STRING, "required": true},
}
# Party ID.
var party_id : String
# The ticket that can be used to cancel matchmaking.
var ticket : String

func _init(p_ex = null).(p_ex):
pass

func serialize() -> Dictionary:
return NakamaSerializer.serialize(self)

func _to_string():
if is_exception(): return get_exception()._to_string()
return "PartyMatchmakerTicket<party_id=%s, ticket=%s>" % [party_id, ticket]

static func create(p_ns : GDScript, p_dict : Dictionary) -> PartyMatchmakerTicket:
return _safe_ret(NakamaSerializer.deserialize(p_ns, "PartyMatchmakerTicket", p_dict), PartyMatchmakerTicket) as PartyMatchmakerTicket

static func get_result_key() -> String:
return "party_matchmaker_ticket"


# Incoming party data delivered from the server.
class PartyData extends NakamaAsyncResult:
const _SCHEMA = {
"party_id": {"name": "party_id", "type": TYPE_STRING, "required": true},
"presence": {"name": "presence", "type": "UserPresence", "required": false},
"op_code": {"name": "op_code", "type": TYPE_INT, "required": true},
"data": {"name": "data", "type": TYPE_STRING, "required": false}
}
# The party ID.
var party_id : String
# A reference to the user presence that sent this data, if any.
var presence : NakamaRTAPI.UserPresence
# Op code value.
var op_code : int
# Data payload, if any.
var data : String

func _init(p_ex = null).(p_ex):
pass

func serialize() -> Dictionary:
return NakamaSerializer.serialize(self)

func _to_string():
if is_exception(): return get_exception()._to_string()
return "PartyData<party_id=%s, presence=%s, op_code=%d, data%s>" % [party_id, presence, op_code, data]

static func create(p_ns : GDScript, p_dict : Dictionary) -> PartyData:
var out := _safe_ret(NakamaSerializer.deserialize(p_ns, "PartyData", p_dict), PartyData) as PartyData
if out.data: # Decode base64 received data
out.data = Marshalls.base64_to_utf8(out.data)
return out

static func get_result_key() -> String:
return "party_data"

# End a party, kicking all party members and closing it. (this is both a message and a result)
class PartyClose extends NakamaAsyncResult:
const _SCHEMA = {
"party_id": {"name": "party_id", "type": TYPE_STRING, "required": true},
}
# Party ID to close.
var party_id : String

func _init(p_ex = null).(p_ex):
pass

func serialize():
return NakamaSerializer.serialize(self)

func get_msg_key() -> String:
return "party_close"

func _to_string():
if is_exception(): return get_exception()._to_string()
return "PartyClose<party_id=%s>" % [party_id]

static func create(p_ns : GDScript, p_dict : Dictionary) -> PartyClose:
return _safe_ret(NakamaSerializer.deserialize(p_ns, "PartyClose", p_dict), PartyClose) as PartyClose

static func get_result_key() -> String:
return "party_close"
Loading

0 comments on commit 3957c8c

Please sign in to comment.