Closed nguyenhaian closed 7 years ago
update: I am using unity free edition version 5.5.1f1.
ios app's logs above are fired on a simulator, when I build to a real device, app's logs are the same android app's logs.
I think as far as android and ios is considered, client supports xamarin platform. I haven't tried building code using unity yet. Maybe you can search for error on internet. If it is working in unity editor, then it should work on android and ios too. It will be helpful if you can provide me with line numbers of error logs.
update: It works on android and ios, the problem is I forgot to change server IP address from 127.0.0.1 to my computer's LAN IP. There is one thing to note that JsonConvert.SerializeObject() function does not work with ios, so I have to use another JSON library, I didn't found the good one. I'm using SimpleJSON for now which is very easy to use but can't serialize 'object' type.
You can close this issue now.
Why it doesn't work in ios? can you give me type of error it is producing right now?
It is because of Newtonsoft.Json library. I use MiniJSON instead, and it works fine.
NotSupportedException: /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System.Reflection.Emit/DynamicMethod.cpp(20) : Unsupported internal call for IL2CPP:DynamicMethod::create_dynamic_method - System.Reflection.Emit is not supported.
at System.Reflection.Emit.DynamicMethod.create_dynamic_method (System.Reflection.Emit.DynamicMethod m) [0x00000] in <filename unknown>:0
at System.Reflection.Emit.DynamicMethod.CreateDynMethod () [0x00000] in <filename unknown>:0
at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[T] (System.Type type) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator (System.Type createdType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateDictionaryContract (System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CanConvertToString (System.Type type) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.GetSerializableMembers (System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (System.Object value) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Formatting formatting, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Formatting formatting, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Formatting formatting) [0x00000] in <filename unknown>:0
You can look at the handshake event:
var authobject = new Dictionary<string, object> {
{ "event", "#handshake" },
{
"data",
new Dictionary<string,object>{ {
"authToken",
AuthToken
} }
},
{
"cid",
Interlocked.Increment (ref counter)
}
};
// var json = JsonConvert.SerializeObject(authobject, Formatting.Indented); // -> ERROR ON iOS
// var json = Json.Serialize (authobject); // WORK
Oh, good. It's nice you were able to understand and edit the code. I will be closing this issue for now.
Hey, do you have account on gitter? If any further problem persist for unity developers who are using this client, I can redirect them to you.
yes. My gitter account is nguyenhaian.
I write a small code to test connectivity. It works well in unity editor. But when I build project to ios/android, there are some errors. Could anyone help me?
ios log:
My socketcluster server got a warning when ios app runs.
Android app log:
There is no log on my socket cluster server when my android app runs.