Why PluginHost.BroadcastEvent sends null data to Unity Client ?

edited July 2017 in Photon Server
hello

We are testing OnRaiseEvent and BroadcastEvent.
and we are able to get data in OnRaiseEvent but when i'm trying to send data from server to unity Client then i'm getting null in data
  public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            base.OnRaiseEvent(info);
             Dictionary<byte , object >  row = new Dictionary<byte, object>() { { 55, "My Testing" }, { 254 ,0 } };
            if (info.IsProcessed)
            {
                this.PluginHost.BroadcastEvent(
                recieverActors: new int[] { 1 },
                senderActor: 0,
                data: row,
                evCode: 55,
                cacheOp: 0,
                sendParameters: new SendParameters() { Unreliable = false });
            }

            return;
        }

where i did mistake please help me to send back data to unity client from OnRaiseEvent


Thanks
Omprakash

Comments

  • Hi @OmiAmarwal,

    This is a known issue and we have documented the workaround
    here
    and
    here.
  • hello @JohnTube

    we have tried hard to send data from BroadcastEvent but we can only get event code not data. data is null
    could you please modify my code so i can proceed further task.

    Thanks
  • i am following your doc instruction.

    This is a known issue. Clients expect events to have a certain predefined structure with well known key codes. 245 for event data and 254 for actor number. To fix this, simply do a minor change in the way you send events data from plugins: instead of (Dictionary)eventData send new Dictionary(){{245,eventData},{254,senderActorNr}}.




  • public override void OnRaiseEvent(IRaiseEventCallInfo info)
            {
                base.OnRaiseEvent(info);
                 Dictionary<byte , object >  row = new Dictionary<byte, object>() { { 55, "My Testing" }, { 254 ,0 } };
                if (info.IsProcessed)
                {
                    this.PluginHost.BroadcastEvent(
                    recieverActors: new int[] { 1 },
                    senderActor: 0,
                    data: new Dictionary<byte, object>() { { 245 , row } },
                    evCode: 55,
                    cacheOp: 0,
                    sendParameters: new SendParameters() { Unreliable = false });
                }
    
                return;
            }
  • Thanks @JohnTube

    this code is working fine
Sign In or Register to comment.