Photon Plugin Not Receiving data in onEvent callback
Options
abhishek
✭
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
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
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
0
Comments
-
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:
fromPluginHost.BroadcastEvent(new int[] { ActorNr }, 0,123, data, (byte)CacheOperations.DoNotCache);
tobyte 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);
0 -
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!
0