# Is possible to call the updateStatus from GO?

**URL:** <https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553>\
**Category:** Client Libraries\
**Tags:** golang\
**Created:** [November 7, 2023, 9:23am UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553 "2023-11-07T09:23:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![j4c0b](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@j4c0b](https://forum.heroiclabs.com/u/j4c0b)\
**Post date:** [November 7, 2023, 9:23am UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553/1 "2023-11-07T09:23:34Z")

</div>

Hello,

we would like to update the Presence status via our RPC function.  
So, not call from Unreal Client this:

```auto
rtClient->updateStatus("{location:game}");

```

But we want to call our RPC function which modify metadata and call updateStatus in one step.Like this:

```auto
Client->RPC(Session, "update_metadata", "{location:game}", RpcSuccessDelegate, RpcErrorDelegate);

```

And in GO, we process this RPC function “update\_metadata” and immediately call something like **updateStatus(payload)**.

Is this possible call presence functions from GO server?

---

<div class="post-metadata">

**Author:** ![csdaraujo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/csdaraujo/32/1351_2.png) [@csdaraujo](https://forum.heroiclabs.com/u/csdaraujo)\
**Post date:** [November 7, 2023, 6:07pm UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553/2 "2023-11-07T18:07:46Z")

</div>

Hi, @j4c0b.

Could you please elaborate in more detail what the goal is so a more appropriate solution can be suggested?

Regards,  
Caetano

---

<div class="post-metadata">

**Author:** ![j4c0b](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@j4c0b](https://forum.heroiclabs.com/u/j4c0b)\
**Post date:** [November 7, 2023, 11:27pm UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553/3 "2023-11-07T23:27:58Z")

</div>

From Unreal, I call

```auto
Client->RPC(Session, "update_metadata", "{location:game}", RpcSuccessDelegate, RpcErrorDelegate);

```

and in GO, I process it like in example

```auto
initializer.RegisterRpc("UpdateMetadata", func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, payload string) (string, error) {
    userId, ok := ctx.Value(runtime.RUNTIME_CTX_USER_ID).(string)
    if !ok {
        return "", errors.New("could not get user ID from context")
    }

    if err := nk.AccountUpdateId(ctx, userId, "", map[string]interface{}{
        "title": "Definitely Not The Imposter",
        "hat": "space_helmet"
        "skin": "alien"},
    }, "", "", "", "", ""); err != nil {
        return "", errors.New("could not update account")
    }

// MY MODIFICATION
// and here I want to call something like
// rtClient->updateStatus("I have new metadata");

    return "{}", nil
})

```

---

<div class="post-metadata">

**Author:** ![csdaraujo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/csdaraujo/32/1351_2.png) [@csdaraujo](https://forum.heroiclabs.com/u/csdaraujo)\
**Post date:** [November 8, 2023, 9:41am UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553/4 "2023-11-08T09:41:34Z")

</div>

> [@j4c0b](#):
>
> `payload`

I’m still not sure what the intention of your proposed solution is but if you need to update the status of a user, it can be done on the [client](https://heroiclabs.com/docs/nakama/concepts/status/). It would add one RPC call but would also keep it simple in terms of server code since this feature (updateStatus) is already implemented on Nakama server and client libraries (no need for custom code).

Regards,  
Caetano

---

<div class="post-metadata">

**Author:** ![j4c0b](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@j4c0b](https://forum.heroiclabs.com/u/j4c0b)\
**Post date:** [November 8, 2023, 9:53am UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553/5 "2023-11-08T09:53:42Z")

</div>

I need to update my Metadata via RPC function “UpdateMetadata” like in my case above.  
And when I update my data, I need every my friend (which follows me) gets the information like “your friend j4c0b updated his metadata”.

I think the best way is via Presence via updateStatus, which can be called from client. You are right.

But I want to do this in one step. I would like to call from client only RPC function “UpdateMetadata” which should call updateStatus(). But how I can get RealTimeClient in my RPC function in GO?

For me, it is much better than call 2 functions from client in callbacks like

```auto
FOnRPC RpcSuccessDelegate;
RpcSuccessDelegate.AddDynamic(this, &ASagiShiActor::OnRpcSuccess);

FOnError RpcErrorDelegate;
RpcErrorDelegate.AddDynamic(this, &ASagiShiActor::OnRpcError);

Client->RPC(Session, "EquipHat", "<PayloadString>", RpcSuccessDelegate, RpcErrorDelegate);

/* Delegate handlers */

void ASagiShiActor::OnRpcSuccess(const FNakamaRPC& RPC)
{
	UE_LOG(LogTemp, Log, TEXT("New hat successfully equipped"));

	FOnSetStatus success;
	success.AddDynamic(this, &ASagiShiActor::OnSetStatusSuccess);

	FOnRtError error;
	error.AddDynamic(this, &ASagiShiActor::OnSetStatusError);
	RealtimeClient->UpdateStatus(TEXT("xjs test"), success, error);
}

void ASagiShiActor::OnRpcError(const FNakamaError& Error)
{
	UE_LOG(LogTemp, Error, TEXT("Error reading storage objects: %s"), *Error.Message);
}

void ASagiShiActor::OnSetStatusSuccess()
{
	UE_LOG(LogTemp, Log, TEXT("New status successfully set"));
}

void ASagiShiActor::OnSetStatusError(const FNakamaRtError& error)
{
	UE_LOG(LogTemp, Error, TEXT("Error set status: %s"), *Error.Message);
}

```

This is very annoying.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 8, 2023, 10:19am UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553/6 "2023-11-08T10:19:54Z")

</div>

@j4c0b I think [notifications](https://heroiclabs.com/docs/nakama/tutorials/unity/pirate-panic/notifications/) would serve your use case well.

---

<div class="post-metadata">

**Author:** ![j4c0b](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@j4c0b](https://forum.heroiclabs.com/u/j4c0b)\
**Post date:** [November 8, 2023, 11:16am UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553/7 "2023-11-08T11:16:35Z")

</div>

@sesposito Thanks, perhaps it helps.  
But when I use notifications, is there any notification for all users who follow me?  
Because,

```auto
rtClient->followUsers({ "<user id>" }, successCallback);

```

and

```auto
rtClient->updateStatus("Hello everyone!");

```

works as “notification” for followers. **And I need this.**

* * *

However, there is still a question. Is it possible to call functions from RealtimeClient in GO server somehow?

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 8, 2023, 1:38pm UTC](https://forum.heroiclabs.com/t/is-possible-to-call-the-updatestatus-from-go/4553/8 "2023-11-08T13:38:26Z")

</div>

Yes, you can invoke custom RPCs from the socket connection.

To use the Notifications API you need to know the users you want to send the data to. If this is all of your friends then you can use the runtime friend listing API and send the notifications with the persist flag to false, so only the ones that are connected to the socket will receive it and it won’t be stored for offline retrieval.

To send the status update from the server you’d need to use [streams](https://heroiclabs.com/docs/nakama/server-framework/streams/#streams).
