Skip to content

Latest commit

 

History

History
438 lines (268 loc) · 15.9 KB

API.md

File metadata and controls

438 lines (268 loc) · 15.9 KB

RequestLib

Contents

API type

Namespace

Kafe.RequestLib

Summary

The only class you should use to Interact with RequestLib.

PlayerInfoUpdate constants

Summary

Called whenever we receive the information about the Mods of a remote player in the current Instance. This is useful if you need to update data of a player of whether they have RequestLib or your Mod installed.

CancelSentRequest(request) method

Summary

Cancels a pending request you sent.

Parameters
Name Type Description
request Kafe.RequestLib.API.Request The request reference.

GetPendingReceivedRequests() method

Summary

Get the currently pending received requests. This might be useful if you want to answer to the requests via the mod, but you don't want to use an interceptor.

Returns

The currently pending request received from your mod from a remote player.

Parameters

This method has no parameters.

GetPendingSentRequests() method

Summary

Retrieve the currently pending sent requests. This might be useful if you want to cancel a request, but you didn't save it previously.

Returns

The currently pending requests sent by your mod.

Parameters

This method has no parameters.

HasMod(playerGuid) method

Summary

Checks whether a remote player in the current Instance has your Mod or not.

Returns

Whether the remote player has your mod installed or not.

Parameters
Name Type Description
playerGuid System.String The Remote Player Guid you want to check.

HasRequestLib(playerGuid) method

Summary

Checks whether a remote player in the current Instance has the RequestLib or not.

Returns

Whether the remote player has the RequestLib installed or not.

Parameters
Name Type Description
playerGuid System.String The Remote Player Guid you want to check.

RegisterMod() method

Summary

Registers your Mod from the RequestLib. You should run this during the initialization of your mod.

Parameters

This method has no parameters.

RegisterMod() method

Summary

Registers your Mod from the RequestLib. You should run this during the initialization of your mod.

Parameters

This method has no parameters.

ResolveReceivedRequest(request,result,metadata) method

Summary

Resolves manually a currently pending request you received.

Parameters
Name Type Description
request Kafe.RequestLib.API.Request The request reference, you can get it from GetPendingReceivedRequests.
result Kafe.RequestLib.API.RequestResult Which answer should be sent as the response.
metadata System.String Optional metadata if you want to send extra info to the requester.

SendRequest(request) method

Summary

Sends a request to a remote player in the Instance.

Parameters
Name Type Description
request Kafe.RequestLib.API.Request Instance of the request you want to send. Use it's constructor to create one.

InterceptorResult type

Namespace

Kafe.RequestLib.API

Summary

Wrapper to hold the information of the Result of an Interceptor.

GetPreventShowingRequest(resultOverride,responseMetadata) method

Summary

Generates a response for the case when you want to prevent the display of a request. This means the request won't appear for the user to reply.

Returns

An InterceptorResult for you to use on your Interceptor function.

Parameters
Name Type Description
resultOverride Kafe.RequestLib.API.RequestResult The result that will be sent to the request. Defaults to not sending anything (Time out).
responseMetadata System.String Optional metadata that can be retrieved by the request initiator.

GetShowRequest() method

Summary

Generates a response for the case when you don't want to prevent the display of a request. This means a request will still appear for the user to reply to.

Returns

An InterceptorResult for you to use on your Interceptor function.

Parameters

This method has no parameters.

PlayerInfo type

Namespace

Kafe.RequestLib.API

Summary

Player info accessible when when we get a Remote Player's info update. Happens whenever someone with the RequestLib joins the Instance.

Guid constants

Summary

The GUID of this Remote Player.

Username constants

Summary

The username of this Remote Player.

HasMod() method

Summary

Check if the Remote Player has your mod Installed.

Returns

Whether this Remote Player has your mod install or not.

Parameters

This method has no parameters.

HasRequestLib() method

Summary

Check if the Remote Player has the RequestLib installed.

Returns

Whether this Remote Player has the Request Library Installed or not.

Parameters

This method has no parameters.

Request type

Namespace

Kafe.RequestLib.API

Summary

Represents a request of RequestLib.

#ctor(targetPlayerGuid,message,onResponse,metadata) constructor

Summary

Constructor of requests, should be used by the Mods to create a request.

Parameters
Name Type Description
targetPlayerGuid System.String Target player guid
message System.String The message to be displayed on the request.
onResponse System.Action{Kafe.RequestLib.API.Request,Kafe.RequestLib.API.Response} The Action that will be called when the player replies or the request times out
metadata System.String Optional metadata that will be available in the Interceptor.

Message constants

Summary

Gets the message to be displayed on the request.

Metadata constants

Summary

Gets the optional metadata that will be available in the Interceptor.

SourcePlayerGuid constants

Summary

Gets the Guid of the source player from whom the request is originating.

TargetPlayerGuid constants

Summary

Gets the Guid of the target player to whom the request is being sent.

RequestHandlers type

Namespace

Kafe.RequestLib.API

Summary

Represents the Handlers on the requested side. It allows to setup an interceptor or a sent response listener.

Inteceptor constants

Summary

Interceptor for the requests.

OnResponseSent constants

Summary

Listener for when a response is going to be sent from the requested side.

RequestResult type

Namespace

Kafe.RequestLib.API

Summary

The possible results of a Request.

Accepted constants

Summary

The request was accepted!

Declined constants

Summary

The request was declined :(

TimedOut constants

Summary

The request didn't get an answer and timed out. Requests time out after 1 minute.

Response type

Namespace

Kafe.RequestLib.API

Summary

Represents a response of RequestLib.

#ctor() constructor

Summary

Internal constructor of responses. Should not be used by Mods!

Parameters

This constructor has no parameters.

Metadata constants

Summary

Gets the optional metadata related to the response. This metadata might provide additional information about the response.

Result constants

Summary

Gets the result of the request. The result can be TimedOut, Accepted, or Declined.