Skip to main content

Custom Pakcet Handler

You can use the Custom Packet handler if you want to use logic that the developer has implemented the processing for a specific message. Below is an example of customizing the processing for findObjects and move requests.

Gamium.PacketTypes.findObjects.SetPreprocessor(PreprocessFindObjects);
Gamium.PacketTypes.findObjects.SetHandler(HandleFindObjects);

Gamium.ActionsTypes.movePlayer.SetPreprocessor(PreprocessMovePlayer);
Gamium.ActionsTypes.movePlayer.SetHandler(HandleMovePlayer);


private static async Task<FindObjectsResultT> HandleFindObjects(FindObjectsParamT param)
{
await Task.Delay(0);
bool isFailed = true;
if (isFailed)
{
throw new Exception("error");
}

// do find objects
return new FindObjectsResultT { Infos = new List<ObjectInfoT>() };
}

private static async Task PreprocessMovePlayer(MovePlayerParamT param)
{
await Task.Delay(0);
Debug.Log("PreprocessMovePlayer");
}


private static async Task<ActionResultT> HandleMovePlayer(MovePlayerParamT param)
{
await Task.Delay(0);
bool isFailed = true;
if (isFailed)
{
throw new Exception("error");
}

// do move player
return new ActionResultT();
}

SetPreprocessor

Implement logic that runs first when a specific message request comes to the Gamium Engine. For example, you can leave a log for a specific message.

SetHandler

Replaces the processing of specific messages with logic implemented by the user. Messages registered by Handler as SetHandler will no longer be processed by the Gamium Engine SDK, but will be processed by the Handler registered by the user.