Photon JS and Photon Unity

no1no
no1no
I've already developed a game using Photon and I'm planning to develop a HTML5 version for it. Is it possible for PhotonJS and Photon Unity to communicate with each other using RPC?

Comments

  • Photon Unity Network plugin is tightly coupled with Unity infrastructure. For instance, RPC makes sense only for Unity objects which have no representation in JS SDK obviously. But some feature like custom events should be compatible (considering data types limitations) with Photon SDKs including JS.
    Note also that PUN adds plugin version to app version string when connects: appVersion + "_" + PhotonNetwork.versionPUN . You need set same version string in JS (or other SDK) clients to be able join same app.
  • So I guess the 2 clients can still communicate then? How can I do it? For example if I want to send a text message from Unity client to a JS client (or vice versa), what should I do?
  • Call PhotonNetwork.RaiseEvent() on PUN side and handle it with LoadBalancingClient.onEvent on JS side.
    Vice versa would be LoadBalancingClient.raiseEvent and PhotonNetwork.OnEventCall
  • Great. Thank you for your answer.
  • vadim wrote:
    Call PhotonNetwork.RaiseEvent() on PUN side and handle it with LoadBalancingClient.onEvent on JS side.
    Vice versa would be LoadBalancingClient.raiseEvent and PhotonNetwork.OnEventCall

    Hi, in my case it works, i use player JS only to sends data ... but has It has a problem ... when user with web JS join in the room server, players with PUN stop looking at each other. And when player JS exit rom, players with PUN can looking at each other.

    any solution?
  • Hi,

    What you mean by "stop looking at each other"? Any errors in your log?
    JS client events may conflict with builtin PUN events (codes 200-255). Make sure that js events codes are below 200
  • i use code 2 to send data and no errors in log.

    actor in unity3D pun send data

    ...
    byte eventCode = 2;
    PhotonNetwork.RaiseEvent (eventCode, pasadataweb, sendReliable, ro);
    ...

    and js web receives

    This works fine and code http can work with data received, but when js-web-actor is on the server, all actors in unity3D-pun are frozen (no serialization) and if new actor-pun enters when js-web-actor it is in the room new actor-pun cant look others actors.

    When js-web-actor leave everything works correctly again.
  • I tried to not send data, no send events, only actor-js join in room ... and i have same error, and when actor-js leave unity3d-pun work ok again.
  • Are you sure about errors?
    I'm trying to reproduce the issue and have a lot of errors in Unity console.
    Would like to know do we have same issue or not. What's in your unity console?
  • sorry I said backwards , and I have the same errors , can you fix them?

    my english is very bad ...
  • hi, trip!
    could you say us what do you send in RaiseEvent. what is in your 'pasadataweb'?
    values, set of types and so on
  • The system (unity pun) stops even if no data is sent (raise), It is only necessary that user web-js join to room.

    When user web-js join to room (no data sent, only join) pun no work and when web-js leave room pun work again.

    anyway ... data i sent is a string
  • We found reason for this in our code and fixed it. but in general you should undestand that JS has its own limitations in data types which can be sent
    so, you should be careful and that is why i'm asking you about exact data you sent
    i would like to see something like this

    var data = new Hashtable()
    {{key, value},
    {key, value},
    ....
    }

    RaiseEvent(code, data)..
  • well, send data work nice for my, no have problem with data ...

    but when player web-js join in room players in unity3d pun no work ...

    (no data send, only join)

    i test with pun 1.56 and same error when web-js actor join to room ...

    this error
    Operation 253 failed in a server-side plugin. Check the configuration in the Dashboard. Message from server-plugin: System.NullReferenceException: Object reference not set to an instance of an object.
    at Photon.SocketServer.ApplicationBase.BroadCastEvent[TPeer](IEventData eventData, IEnumerable`1 peers, SendParameters sendParameters) in h:\svncontent\photon-socketserver-sdk_4.0\src\Photon.SocketServer\ApplicationBase.cs:line 297
    at Photon.Hive.Room.PublishEvent(HiveEventBase e, IEnumerable`1 actorList, SendParameters sendParameters) in d:\dev\photon-socketserver-sdk_4.0\src-server\Hive\PhotonHive\Room.cs:line 367
    at Photon.Hive.HiveGame.RaiseEventOperationHandler(HivePeer peer, RaiseEventRequest raiseEventRequest, SendParameters sendParameters, Actor actor) in d:\dev\photon-socketserver-sdk_4.0\src-server\Hive\PhotonHive\HiveGame.cs:line 1432
    at Photon.Hive.HiveHostGame.ProcessRaiseEvent(HivePeer peer, RaiseEventRequest raiseEventRequest, SendParameters sendParameters, Actor actor) in d:\dev\photon-socketserver-sdk_4.0\src-server\Hive\PhotonHive\HiveHostGame.cs:line 1549
    at Photon.Hive.HiveHostGame.<>c__DisplayClass64.<HandleRaiseEventOperation>b__63() in d:\dev\photon-socketserver-sdk_4.0\src-server\Hive\PhotonHive\HiveHostGame.cs:line 1089
    at Photon.Hive.Plugin.CallInfo.Continue() in d:\dev\photon-socketserver-sdk_4.0\src-server\Hive\PhotonHive\Plugin\CallInfo.cs:line 135
    at Photon.Hive.Plugin.PluginBase.OnRaiseEvent(IRaiseEventCallInfo info) in d:\dev\photon-socketserver-sdk_4.0\src-server\HivePlugin\PluginBase.cs:line 378
    at Photon.Hive.Plugin.PluginBase.Photon.Hive.Plugin.IGamePlugin.OnRaiseEvent(IRaiseEventCallInfo info) in d:\dev\photon-socketserver-sdk_4.0\src-server\HivePlugin\PluginBase.cs:line 229
    UnityEngine.Debug:LogError(Object)
    NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Plugins/PhotonNetwork/NetworkingPeer.cs:1108)
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    PhotonHandler:Update() (at Assets/Plugins/PhotonNetwork/PhotonHandler.cs:83)
  • yes, good

    Please send me line of code from Unity version of your game where do you send Raise Event operation
    that is all what i need
  • the server error appears even if not sent event raise
  • you are just like secret agent.

    let's close this topic