raiseCustomEventWithCode disconnects peer

Izmy
Izmy ✭✭
edited January 2015 in Flash (deprecated)
Hello friends!

I am trying to execute custom event with code from my as3 app:
var data:Dictionary = new Dictionary();
data["message"] = clip.inpuptLine.inputLabel.text + "";
Stats.main.getPhotonInstance().raiseCustomEventWithCode(32, data);

As you could see this is pretty much like your chat demo code. But this code leads to disconnect from the server with such error:
2015-01-05 01:57:31,555 [14] DEBUG Lite.Room [(null)] - Executing operation Join
2015-01-05 01:57:31,556 [14] DEBUG Lite.LiteGame [(null)] - We got game room.
2015-01-05 01:57:31,556 [14] DEBUG Lite.Room [(null)] - Join operation from IP: 127.0.0.1 to port: 4530
2015-01-05 01:57:31,557 [14] DEBUG Lite.Room [(null)] - Actor added: 1 to game: ADMINS
2015-01-05 01:57:31,567 [14] DEBUG Photon.SocketServer.PeerBase [(null)] - SentOpResponse: ConnID=136, opCode=255, return=0, ChannelId=1 result=Ok size=13 bytes
2015-01-05 01:57:41,299 [14] DEBUG Photon.SocketServer.Rpc.Protocols.Amf3.Amf3Reader [(null)] - Unknown amf3 type marker 17 at position 12
2015-01-05 01:57:41,306 [14] DEBUG Photon.SocketServer.PeerBase [(null)] - Failed to parse operation request for peer with connection id 136.
2015-01-05 01:57:41,306 [14] WARN  Photon.SocketServer.PeerBase [(null)] - Disconnecting peer 136: Unexpected data received
2015-01-05 01:57:41,307 [14] DEBUG Photon.SocketServer.PeerBase [(null)] - Peer 136 changed state from Connected to Disconnecting
2015-01-05 01:57:41,308 [14] DEBUG Photon.SocketServer.PeerBase [(null)] - Disconnect client called

Would you kindy suggest me how could we fix such issue?

Thank you!

Best regards,
Alexander

Comments

  • Hi,

    Use plain object instead of Dictionary
    var data:Object = {};
    data["message"] = ...
    
  • Thanks!
    With plain object it works like a charm.

    And just one additional question:
    To parse required data I use:
    data[245][1]
    

    But, when I parse operations from the server I could directly access to data[1]. or whatever byte I configure on the server.
    So why riseCustomEvent doesn't work in the same way ([245] required)?

    Thank you!

    Best regards,
    Alexander
  • Please clarify where do you use [245] to parse data.
    When custom event received, LoadBalancingClient.onEvent() called with content already extracted from message.
  • Yes, sure!
    Now it is something like this:
    switch (eventCode)
    			{
    				case 123:
    				{
    					if (data[245][1] != null)
    					{
    						chat.text += data[245][1];
    					}
    					break;
    				}
    

    But if I send any operation with data from the server, I could use:
    case 124:
    					if (data[1] != null)
    					{
    						chat.text += data[1];
    					}
    					break;
    
  • The code still does not show where it happen (which methods).
    I guess the difference is between custom event sent from client with payload in [245] and server's custom message with data in [1]. If so, they are different messages and not necessary should be parsed same way.