# Handle Match found on server side

**URL:** <https://forum.heroiclabs.com/t/handle-match-found-on-server-side/746>\
**Category:** Local Setup\
**Tags:** server-framework\
**Created:** [May 16, 2020, 8:33pm UTC](https://forum.heroiclabs.com/t/handle-match-found-on-server-side/746 "2020-05-16T20:33:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jules](https://forum.heroiclabs.com/u/Jules)\
**Post date:** [May 16, 2020, 8:33pm UTC](https://forum.heroiclabs.com/t/handle-match-found-on-server-side/746/1 "2020-05-16T20:33:14Z")

</div>

Hey there.

Is there a way to catch the MatchMakerMatched result on the server side in Lua, to run some logic when a opponent was found, for example to store an asynchronous match in the db without forcing the client to make another rpc call to the server, so that most of the things are handled by the server:

1. client clicks on a button to find a match
2. nakama matchmaker finds an opponent
3. before sending the result to the client i want to run some code (is there a after hook to do such things)?
4. result sent to the client as information about new created match only

thank you

---

<div class="post-metadata">

**Author:** ![Koop](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@Koop](https://forum.heroiclabs.com/u/Koop)\
**Post date:** [May 16, 2020, 8:51pm UTC](https://forum.heroiclabs.com/t/handle-match-found-on-server-side/746/2 "2020-05-16T20:51:22Z")

</div>

There is the [matchmaker matched hook](https://heroiclabs.com/docs/runtime-code-basics/#register-hooks).

> If you’d like to run server code when the matchmaker has matched players together, register your function using the following.  
> nk.register\_matchmaker\_matched()

It is used for [authoritative match](https://heroiclabs.com/docs/gameplay-multiplayer-server-multiplayer/#matchmaker).

---

<div class="post-metadata">

**Author:** ![Jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jules](https://forum.heroiclabs.com/u/Jules)\
**Post date:** [May 16, 2020, 8:55pm UTC](https://forum.heroiclabs.com/t/handle-match-found-on-server-side/746/3 "2020-05-16T20:55:53Z")

</div>

i would not need it for authoritative match. only to run code after opponent found…does it work as well?

---

<div class="post-metadata">

**Author:** ![Koop](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@Koop](https://forum.heroiclabs.com/u/Koop)\
**Post date:** [May 16, 2020, 10:11pm UTC](https://forum.heroiclabs.com/t/handle-match-found-on-server-side/746/4 "2020-05-16T22:11:26Z")

</div>

Yes you have to return nil for peer-to-peer relayed mode: [reference](https://heroiclabs.com/docs/runtime-code-function-reference/#register-hooks)

---

<div class="post-metadata">

**Author:** ![Jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jules](https://forum.heroiclabs.com/u/Jules)\
**Post date:** [May 16, 2020, 10:36pm UTC](https://forum.heroiclabs.com/t/handle-match-found-on-server-side/746/5 "2020-05-16T22:36:34Z")

</div>

great thank you
