BroadCastEvent Impersonate Actor

Hi there, I have started exploring and prototyping within our existing codebase and I tried sending a message for an emote, using the eventCode for the type of emote and leaving the message data empty. Initially, I caught the message on the plugin and tried to propagate it to the other users, but I couldn't get the sender to appear correctly on the receiving end. Apparently the message gets from the sender to the right users correctly if I don't catch it, which makes sense, so for now that is a way around my issue.
However, in the future, we might want to batch these emote calls (possibly with other general messages). I found in the documentation that the second parameter to BroadcastEvent should allow me to impersonate an actor from the server. Whenever I sent messages this way,
PluginHost.BroadcastEvent(1, info.ActorNr, 0, EMOTE_CODE, data, CacheOperations.DoNotCache, sendParameters);
the Sender in the EventData on the client always ended up being 0, signifying the server, I think.
Other solutions I found among our tests have the sender ID in the custom data, which seems like unnecessary data traffic if there is a sender field by default. Am I misunderstanding the use of the parameter or is this maybe something that has already been fixed in a later version?
For reference, we are not on the latest version (yet), although I would like to see if it is worth updating and how easy that may be. The PhotonHivePlugin dll is Version 1.0.15.11060 (Runtime Version is v4.0.30319).

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @ErikTacx,

    Thank you for choosing Photon!

    Instead of sending a empty or null data, try to format the data the way the client expects it (at least in the official client C# SDKs):
    Dictionary<byte, object> data = new Dictionary<byte, object>{ { 254, senderActorNumber}, { 245, actualData } };
    
    This way the client can always received the sender's ActorNumber as you set it from the plugins' BroadcastEvent call.
    Read more here or here.