如何使用Photon进行配对?

时间:2016-01-17 14:08:23

标签: c# unity3d photon

我用这段代码加入光子房间:

RoomOptions newRoomOptions = new RoomOptions();
newRoomOptions.isOpen = true;
newRoomOptions.isVisible = true;
newRoomOptions.maxPlayers = 2;
// L is League 
newRoomOptions.customRoomPropertiesForLobby = new string[] { "L" };
newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "L", 8 } };

TypedLobby sqlLobby = new TypedLobby(GAME_LOBBY_NAME, LobbyType.SqlLobby);
PhotonNetwork.CreateRoom(null, newRoomOptions, sqlLobby);

和这段代码来创建一个房间:

Operation failed: OperationResponse 225: ReturnCode: -2 (SQL logic error or missing database
no such column: L). Parameters: {} Server: MasterServer

我从Photon文档中获取此代码https://doc.photonengine.com/en/pun/current/tutorials/matchmaking-and-lobby 但这引发了例外:

01-18 21:02:08.101  28838-28838/thamarai.techundefined.com E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: thamarai.techundefined.com, PID: 28838
    com.firebase.client.FirebaseException: Failed to bounce to type
            at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:185)
            at net.simplifiedcoding.imageuploadsample.ProcessImages$2.onDataChange(ProcessImages.java:144)
            at com.firebase.client.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:53)
            at com.firebase.client.core.view.DataEvent.fire(DataEvent.java:45)
            at com.firebase.client.core.view.EventRaiser$1.run(EventRaiser.java:38)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5086)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class net.simplifiedcoding.imageuploadsample.ProcessImages$RetriveUserData]: can not instantiate from JSON object (need to add/enable type information?)
            at [Source: java.io.StringReader@41c63110; line: 1, column: 2]
            at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:984)
            at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:276)
            at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
            at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
            at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
            at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:183)
            at net.simplifiedcoding.imageuploadsample.ProcessImages$2.onDataChange(ProcessImages.java:144)
            at com.firebase.client.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:53)
            at com.firebase.client.core.view.DataEvent.fire(DataEvent.java:45)
            at com.firebase.client.core.view.EventRaiser$1.run(EventRaiser.java:38)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5086)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

感谢。

1 个答案:

答案 0 :(得分:2)

使用C0..C9属性而不是L。

来自docs: 在内部,SQL-lobbies在SQLite表中列出了最多10个特殊"过滤属性"的房间。目前,这些命名固定为:" C0"," C1"达到" C9"。