Primitive types are not allowed! in opGetPropertiesOfActor

Options
Hi!

I tried to use peer operation:
public boolean opGetPropertiesOfActor(int[] actorNrList,
                                      byte[] properties,
                                      byte channelId)
And get next exception:
02-27 18:10:58.367: E/AndroidRuntime(26572): java.lang.UnsupportedOperationException: Primitive types are not allowed! Please use same wrap classes instead (Short for short, Integer for int etc).
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.Protocol.serialize(Protocol.java:260)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.Protocol.serializeParameters(Protocol.java:118)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.EnetPeer.serializeOperation(EnetPeer.java:294)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.EnetPeer.sendOperation(EnetPeer.java:276)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.PhotonPeer.opCustom(PhotonPeer.java:581)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.LitePeer.opGetPropertiesOfActor(LitePeer.java:121)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at com.slobodastudio.discussions.photon.PhotonService.opRequestActorsInfo(PhotonService.java:370)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at com.slobodastudio.discussions.photon.PhotonService.onEvent(PhotonService.java:173)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.PeerBase.parsePacket(PeerBase.java:326)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.EnetPeer.dispatchIncomingCommands(EnetPeer.java:230)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at de.exitgames.client.photon.PhotonPeer.dispatchIncomingCommands(PhotonPeer.java:523)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at com.slobodastudio.discussions.photon.PhotonService$1.run(PhotonService.java:392)
02-27 18:10:58.367: E/AndroidRuntime(26572): 	at java.util.Timer$TimerImpl.run(Timer.java:284)
Can you tell me please how to get actor properties?

Comments

  • Tobias
    Options
    Interesting bug.
    I think I see where this is coming from but, just to be sure: What values are you passing actually?

    We likely need to provide you with a bugfix release.
  • Thanks for reply, please find my client code below:
    @Override
    public void onEvent(final EventData event) {
    
    		switch (event.Code.byteValue()) {
    			case LiteEventCode.Join:
    				Integer[] actorsInGame = (Integer[]) event.Parameters.get(LiteEventKey.ActorList.value());
    				ArrayList<Integer> unknownActors = new ArrayList<Integer>();
    				for (int i : actorsInGame) {
    					if ((i != localUser.getUserId()) && !onlineUsers.containsKey(i)) {
    						unknownActors.add(i);
    					}
    				}
    				if (unknownActors.size() > 0) {
    					opRequestActorsInfo(unknownActors);
    				}
    				break;
    		}
    }
    
    private boolean opRequestActorsInfo(final ArrayList<Integer> integerList) {
    
    		int[] intArray = new int[integerList.size()];
    		for (int i = 0; i < integerList.size(); i++) {
    		intArray[i] = integerList.get(i);
    		}
    		return peer.opGetPropertiesOfActor(intArray , new byte[]{LiteOpPropertyType.ACTOR}, (byte)0);	
    	}
    
  • Tobias
    Options
    The values look ok, so I assume the bug is in the lib.
    We will update asap but I can't promise exactly when. Sorry for that.

    As workaround, you can re-implement the operation yourself.
    This is how it's implemented now:
    public boolean opGetPropertiesOfActor(int[] actorNrList, byte[] properties, byte channelId)
    {
    	TypedHashMap<Byte, Object> opParameters = new TypedHashMap<Byte, Object>(Byte.class, Object.class);
    	opParameters.put((byte)LiteOpKey.Properties, LitePropertyTypes.Actor);
    	if (properties != null)
    	{
    		opParameters.put((byte)LiteOpKey.ActorProperties, properties);
    	}
    
    	if (actorNrList != null)
    	{
    		opParameters.put((byte)LiteOpKey.ActorList, actorNrList);
    	}
    
    	return opCustom((byte)LiteOpCode.GetProperties, opParameters, true, channelId);
    }
    

    This is how it should work (not tested). Note line 4 "(byte)LitePropertyTypes.Actor.value()":
    public boolean opGetPropertiesOfActor(int[] actorNrList, byte[] properties, byte channelId)
    {
    	TypedHashMap<Byte, Object> opParameters = new TypedHashMap<Byte, Object>(Byte.class, Object.class);
    	opParameters.put((byte)LiteOpKey.Properties, (byte)LitePropertyTypes.Actor.value());
    	if (properties != null)
    	{
    		opParameters.put((byte)LiteOpKey.ActorProperties, properties);
    	}
    
    	if (actorNrList != null)
    	{
    		opParameters.put((byte)LiteOpKey.ActorList, actorNrList);
    	}
    
    	return opCustom((byte)LiteOpCode.GetProperties, opParameters, true, channelId);
    }
    

    In the end, LitePropertyTypes.Actor is simply 2.
    Hope this helps.
  • billTCP
    Options
    Hi Tobias, I am using the Photon-Android_v3-0-0-0-RC1_SDK version, but I still got this problem described above. The code keeps throwing out error "java.lang.UnsupportedOperationException: Primitive types are not allowed!" if I call the OpGetPropertiesOfActor. Has this bug already been fixed? And it seems this error remains even after I re-implemented the OpGetPropertiesOfActor with the code you gave.

    Thanks!
  • Tobias
    Options
    billTCP: You're right - it didn't work.

    It should be fixed in Photon-Android_v3-0-0-1_SDK.zip (available now). Please download here:
    https://www.exitgames.com/Download/Photon
  • billTCP
    Options
    Thanks for your fast response. I have now downloaded the new version sdk , but what puzzles me is that why there are so many inconsistency among the different versions in the android platform? For LiteEventCode, LiteOpCode, LiteEventKey and Lite EventCode, sometimes it needs a value() method to convert to byte, and sometimes it is already byte type and the value() method is unnecessary. So, I don't know whether it is a proper request, could these codes all be united?

    What I met is that in the onEvent method, the usual switch-case method now report some error:
    	switch(eventData.Code)
    			{
    			// case (byte)LiteEventCode.Join.value():
    			case (byte) LiteEventCode.Join.value():
    
    It gives the error "case expressions must be constant expressions". I checked the demo code in the demo-realtime source, it uses if-else instead of switch-case. Is this some kind of bug?

    Thanks!
  • Tobias
    Options
    We recently had "help" from external developers with the Android lib and these inconsistencies are part of the result.
    We would like to clean up but will need some time.

    I didn't recognize how the demo now handles events (if,else). :roll:
    I will discuss these issues and see what time we can invest.
  • Tobias
    Options
    I will put some work into it today and tomorrow morning, removing the enums, to make switches work as before.
    I just didn't notice this pre-release.
  • billTCP
    Options
    I just changed the switch-case logic to if-else, and it seems to work fine... And the onOperationResponse() method has the same problem, I fixed my problem by using if-else. Hope you can eliminate such puzzles soon.... Thanks very much for your explanation.
  • Tobias
    Options
    I took a look and replaced a few enums with classes of static final fields.
    For events (e.g.) it is essential that you (as developer) can extend the range of event-codes. This is not easily done with enums and so constants are better.
    I adjusted the demos accordingly and the new SDK is uploaded.