Skip to content

Commit

Permalink
fixes for StreamData, MatchData and MatchDataSend types (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam authored May 2, 2022
1 parent dae57b9 commit b05678d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/nakama-js/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ export interface StreamId {
export interface StreamData {
/** The stream identifier. */
stream: StreamId;
/** Array of presences to receive stream data. */
stream_presence: Presence;
/** The data to send. */
/** A reference to the user presence that sent this data, if any. */
sender?: Presence;
/** Arbitrary contents of the data message. */
data: string;
/** True if this data was delivered reliably. */
reliable?: boolean;
}

/** Presence updates. */
Expand Down Expand Up @@ -305,8 +307,10 @@ export interface MatchData {
op_code: number;
/** Data payload, if any. */
data: Uint8Array;
/** A reference to the user presences that sent this data, if any. */
presences: Presence[];
/** A reference to the user presence that sent this data, if any. */
presence?: Presence;
/** True if this data was delivered reliably. */
reliable?: boolean;
}

/** Send a message that contains match data. */
Expand All @@ -320,6 +324,8 @@ interface MatchDataSend {
data: string | Uint8Array;
/** A reference to the user presences to send this data to, if any. */
presences: Presence[];
/** True if the data should be sent reliably. */
reliable?: boolean;
}
}

Expand Down Expand Up @@ -1140,14 +1146,15 @@ export class DefaultSocket implements Socket {
return response.rpc;
}

async sendMatchState(matchId: string, opCode : number, data: string | Uint8Array, presences? : Presence[]): Promise<void> {
async sendMatchState(matchId: string, opCode : number, data: string | Uint8Array, presences? : Presence[], reliable?: boolean): Promise<void> {
return this.send(
{
match_data_send: {
match_id : matchId,
op_code: opCode,
data: data,
presences: presences ?? []
presences: presences ?? [],
reliable: reliable
}
});
}
Expand Down

0 comments on commit b05678d

Please sign in to comment.