Photon Plugin Not Receiving data in onEvent callback

abhishek
abhishek
edited March 2018 in Photon Server
Hi,

I am trying to implement a Plugin. Inside OnRaiseEvent i am IPluginHost.BroadcastEvent. I have a Javascript PhotonLoadbalancingClient which receives OnEvent callback with proper Event Code. The prblm is i am not receiving the data. Here is my code

Server
public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            //base.OnRaiseEvent(info);
            IPluginHost host = this.PluginHost;
            int eventCode = info.Request.EvCode;
            int ActorNr = info.ActorNr;

            host.LogInfo("Event Code " + info.Request.EvCode+" ActorNr "+ ActorNr);

            var data = new Dictionary<byte, object>
                {
                    {0, 1},
                };
          
            host.BroadcastEvent(new int[] { ActorNr }, 0,123, data, (byte)CacheOperations.DoNotCache);
        }
Javascript Client
onEvent(code: number, content: Object, actorNr: number) {
        super.onEvent(code, content, actorNr);
        this.logger.info("onEvent", code, "content:", content, "actor:", actorNr);
    }
Inside onEvent
code is 123 which is correct
but both content and actorNr both are undefined.
I need to access data which i am passing in Broadcast Event on my Client.

Please help me out

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2016
    Hi @abhishek,

    Yes this is a known issue. We should probably update the documentation to cover it.

    Please do a minor change in the way you send events from plugin:

    from

    PluginHost.BroadcastEvent(new int[] { ActorNr }, 0,123, data, (byte)CacheOperations.DoNotCache);

    to
    byte senderActorNr = 0; // change this if you want, plugin/server should have 0 as actor number.
    PluginHost.BroadcastEvent(new int[] { ActorNr }, 0,123, new Dictionary<byte, object>() { { 245, data }, {254, senderActorNr} }, (byte)CacheOperations.DoNotCache);
  • You have switched the codes for "data" and "senderActorNr" in the documentation https://doc.photonengine.com/en-us/onpremise/current/plugins/manual#events. Costed some time but finally I found this post. Thanks!