Changing the username after connected.

How I have my game working is that the player will log in their account and then choose their character. Right now I have it so when the player logs in to their account it will connect them to the lobby. When they choose their character and channel (or room name) they will connect to the chat service. The problem I am having is that when they send the message it will send the message as the account name. I am using PlayFab's system for accounts. How can I send the characters name instead of their PlayFab ID?


  • JohnTube
    JohnTube mod
    edited July 2016
    Hi @Skeeter135,

    Did you solve the other issue here?

    This is a known issue yes. Unfortunately, Nicknames (also called Usernames) are not fully implemented yet in Photon Chat, however we are suggesting 2 workarounds for our customers:

    1. client stores Photon Nickname per Photon UserID:

    For PlayFab integration it's easier since Photon UserID == PlayFabID
    so all you need is to bind Photon Nickname to PlayFab's (Username or (Title) DisplayName) if any
    client should get other players' Photon Nicknames from PlayFab directly ONCE (on first contact with that UserID) and cache it (maybe update it every once in a while to check if it has not changed).

    2. clients send Photon Nickname in the message itself (what we recommend):

    A. Sender:
    Send local player Nickname inside the message itself in ChatClient.SendPrivateMessage() or ChatClient.PublishMessage().
    The message could be an encoded string, prefarably in JSON as follows:
    {"Message":<custom chat message>, "Nickname":<nickname>}
    Or the message can be any other Photon serializable container:
    - eg. Hashtable, {{"Nickname":<nickname>}, {"Message":<custom chat message>}}
    - eg. string[], [<username>, <custom chat message>]
    - etc.
    B. Receiver:
    Inside IChatClientListener.OnGetMessages() and IChatClientListener.OnPrivateMessage()
    Parse each "message object" to retrieve the implicit and actual text message and also the Nickname.

  • Okay, thanks I got both of the problems to work now thanks.