From 19b8e377c41e799825bb543db5e53df6226d1726 Mon Sep 17 00:00:00 2001 From: oneRain Date: Wed, 27 Jan 2021 11:45:44 +0800 Subject: [PATCH 1/7] fix: get non-exist key exception --- Realtime/Realtime/Conversation/LCIMConversation.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Realtime/Realtime/Conversation/LCIMConversation.cs b/Realtime/Realtime/Conversation/LCIMConversation.cs index f74ace8..ed6e75b 100644 --- a/Realtime/Realtime/Conversation/LCIMConversation.cs +++ b/Realtime/Realtime/Conversation/LCIMConversation.cs @@ -136,7 +136,10 @@ namespace LeanCloud.Realtime { /// public object this[string key] { get { - return customProperties[key]; + if (customProperties.TryGetValue(key, out object val)) { + return val; + } + return null; } set { customProperties[key] = value; From 1de886ea1ef80bb43ff5b0696bc5cceae50c31d8 Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 1 Feb 2021 16:55:24 +0800 Subject: [PATCH 2/7] * mono_crash.11a6748113.0.json: * Realtime.csproj: * Realtime-Unity.csproj: chore: update protobuf. --- Realtime/Realtime-Unity/Realtime-Unity.csproj | 2 +- .../mono_crash.11a6748113.0.json | 724 ++++++++++++++++++ Realtime/Realtime/Realtime.csproj | 2 +- 3 files changed, 726 insertions(+), 2 deletions(-) create mode 100644 Realtime/Realtime-Unity/mono_crash.11a6748113.0.json diff --git a/Realtime/Realtime-Unity/Realtime-Unity.csproj b/Realtime/Realtime-Unity/Realtime-Unity.csproj index c73c438..70af818 100644 --- a/Realtime/Realtime-Unity/Realtime-Unity.csproj +++ b/Realtime/Realtime-Unity/Realtime-Unity.csproj @@ -127,6 +127,6 @@ - + diff --git a/Realtime/Realtime-Unity/mono_crash.11a6748113.0.json b/Realtime/Realtime-Unity/mono_crash.11a6748113.0.json new file mode 100644 index 0000000..d03d2ae --- /dev/null +++ b/Realtime/Realtime-Unity/mono_crash.11a6748113.0.json @@ -0,0 +1,724 @@ +{ + "protocol_version" : "0.0.6", + "configuration" : { + "version" : "(6.12.0.113) (2020-02/4fdfb5b1fd5)", + "tlc" : "normal", + "sigsgev" : "altstack", + "notifications" : "kqueue", + "architecture" : "amd64", + "disabled_features" : "none", + "smallconfig" : "disabled", + "bigarrays" : "disabled", + "softdebug" : "enabled", + "interpreter" : "enabled", + "llvm_support" : "0", + "suspend" : "hybrid" + }, + "memory" : { + "Resident Size" : "139730944", + "Virtual Size" : "4704305152", + "minor_gc_time" : "0", + "major_gc_time" : "0", + "minor_gc_count" : "0", + "major_gc_count" : "0", + "major_gc_time_concurrent" : "0" + }, + "threads" : [ + { + "is_managed" : false, + "offset_free_hash" : "0x0", + "offset_rich_hash" : "0x0", + "crashed" : false, + "native_thread_id" : "0x70000bfee000", + "thread_info_addr" : "0x7f882d02c000", + "thread_name" : "Finalizer", + "ctx" : { + "IP" : "0x7fff67c69e36", + "SP" : "0x70000bfedeb8", + "BP" : "0x70000bfedf00" + }, + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0x10733ca06", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d8165", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d7e97", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1073a89d0", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67d215fd", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "unregistered" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d8dad", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67d2d109", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67d28b8b", + "native_offset" : "0x00000" + } + + ] + }, + { + "is_managed" : false, + "offset_free_hash" : "0x0", + "offset_rich_hash" : "0x0", + "crashed" : false, + "native_thread_id" : "0x1162a5dc0", + "thread_info_addr" : "0x7f882a80a000", + "thread_name" : "tid_307", + "ctx" : { + "IP" : "0x7fff67c6c882", + "SP" : "0x7ffee8973bf8", + "BP" : "0x7ffee8973c90" + }, + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0x10733ca06", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d8165", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d7e97", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1073a89d0", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67d215fd", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "unregistered" + } +, + { + "is_managed" : "false", + "native_address" : "0x107572ee0", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10758afc1", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d5084", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d4e8a", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1073020fa", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10728e1e8", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67b28cc9", + "native_offset" : "0x00000" + } + + ] + }, + { + "is_managed" : true, + "offset_free_hash" : "0x11a6748113", + "offset_rich_hash" : "0x11a6748628", + "crashed" : true, + "native_thread_id" : "0x70000e36a000", + "thread_info_addr" : "0x7f882d258a00", + "thread_name" : "tid_6303", + "ctx" : { + "IP" : "0x7fff67c7033a", + "SP" : "0x70000e362b98", + "BP" : "0x70000e362bc0" + }, + "managed_frames" : [ + { + "is_managed" : "false", + "native_address" : "unregistered" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00015" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x6004287", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x0026a" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x6004487", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x00043" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed4", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00071" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed2", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed1", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x0002b" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x6004286", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x00093" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0xffffffff" + } +, + { + "is_managed" : "false", + "native_address" : "unregistered" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x600447f", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x0003a" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001f2c", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00025" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed4", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00071" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed2", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed1", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x0002b" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x0002a" + } + + ], + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0x10733ca06", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d8165", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d87da", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1073a9a97", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10734169e", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1073a8d8f", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67d215fd", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "unregistered" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67bf7808", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x107595f67", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x107576def", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1075963fe", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10759657f", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1075965ba", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10758ad8e", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d26d1", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d934d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d6fbc", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x6004287", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x6004487", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed4", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed2", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2f196993", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2f195dfe", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2f195cf7", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2f19892b", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2daa7b05", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2da79304", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2da79250", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2da77d79", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2da76e3e", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff2daff489", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10e1fdfcc", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x00000", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", + "token" : "0x600447f", + "native_offset" : "0x0", + "filename" : "System.dll", + "sizeofimage" : "0x292000", + "timestamp" : "0xc58d4017", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001f2c", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "true", + "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", + "token" : "0x6001ed2", + "native_offset" : "0x0", + "filename" : "mscorlib.dll", + "sizeofimage" : "0x472000", + "timestamp" : "0x86058d7a", + "il_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x10729e9d2", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074adf97", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074b4840", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1074d8ded", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67d2d109", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7fff67d28b8b", + "native_offset" : "0x00000" + } + + ] +} +] +} \ No newline at end of file diff --git a/Realtime/Realtime/Realtime.csproj b/Realtime/Realtime/Realtime.csproj index 537885a..a33af4f 100644 --- a/Realtime/Realtime/Realtime.csproj +++ b/Realtime/Realtime/Realtime.csproj @@ -8,7 +8,7 @@ - + From 8645caf4a3d1eddf3f104bcfd80e1b0ea7d8068f Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 1 Feb 2021 16:56:38 +0800 Subject: [PATCH 3/7] fix: ws receive buffer size. --- .../Internal/LCLiveQueryConnection.cs | 4 +-- .../Internal/Connection/LCConnection.cs | 4 +-- .../Internal/WebSocket/LCWebSocketClient.cs | 28 ++++++++++++++----- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/LiveQuery/LiveQuery/Internal/LCLiveQueryConnection.cs b/LiveQuery/LiveQuery/Internal/LCLiveQueryConnection.cs index d2e4466..d11a33e 100644 --- a/LiveQuery/LiveQuery/Internal/LCLiveQueryConnection.cs +++ b/LiveQuery/LiveQuery/Internal/LCLiveQueryConnection.cs @@ -136,9 +136,9 @@ namespace LeanCloud.LiveQuery.Internal { await client.Close(); } - private void OnClientMessage(byte[] bytes) { + private void OnClientMessage(byte[] bytes, int length) { try { - string json = Encoding.UTF8.GetString(bytes); + string json = Encoding.UTF8.GetString(bytes, 0, length); Dictionary msg = JsonConvert.DeserializeObject>(json, LCJsonConverter.Default); LCLogger.Debug($"{id} <= {json}"); diff --git a/Realtime/Realtime/Internal/Connection/LCConnection.cs b/Realtime/Realtime/Internal/Connection/LCConnection.cs index 8e3d1d5..5716a74 100644 --- a/Realtime/Realtime/Internal/Connection/LCConnection.cs +++ b/Realtime/Realtime/Internal/Connection/LCConnection.cs @@ -160,9 +160,9 @@ namespace LeanCloud.Realtime.Internal.Connection { } } - private void OnMessage(byte[] bytes) { + private void OnMessage(byte[] bytes, int length) { try { - GenericCommand command = GenericCommand.Parser.ParseFrom(bytes); + GenericCommand command = GenericCommand.Parser.ParseFrom(bytes, 0, length); LCLogger.Debug($"{id} <= {FormatCommand(command)}"); if (command.HasI) { // 应答 diff --git a/Realtime/Realtime/Internal/WebSocket/LCWebSocketClient.cs b/Realtime/Realtime/Internal/WebSocket/LCWebSocketClient.cs index 1a6e5e4..6c6456f 100644 --- a/Realtime/Realtime/Internal/WebSocket/LCWebSocketClient.cs +++ b/Realtime/Realtime/Internal/WebSocket/LCWebSocketClient.cs @@ -6,13 +6,15 @@ using System.Text; namespace LeanCloud.Realtime.Internal.WebSocket { public class LCWebSocketClient { // .net standard 2.0 好像在拼合 Frame 时有 bug,所以将这个值调整大一些 - private const int RECV_BUFFER_SIZE = 1024 * 5; + private const int SEND_BUFFER_SIZE = 1024 * 5; + private const int RECV_BUFFER_SIZE = 1024 * 8; + private const int MSG_BUFFER_SIZE = 1024 * 10; private const int CLOSE_TIMEOUT = 5000; private const int CONNECT_TIMEOUT = 10000; - public Action OnMessage; + public Action OnMessage; public Action OnClose; @@ -23,6 +25,7 @@ namespace LeanCloud.Realtime.Internal.WebSocket { LCLogger.Debug($"Connecting WebSocket: {server}"); Task timeoutTask = Task.Delay(CONNECT_TIMEOUT); ws = new ClientWebSocket(); + ws.Options.SetBuffer(RECV_BUFFER_SIZE, SEND_BUFFER_SIZE); if (!string.IsNullOrEmpty(subProtocol)) { ws.Options.AddSubProtocol(subProtocol); } @@ -78,10 +81,12 @@ namespace LeanCloud.Realtime.Internal.WebSocket { } private async Task StartReceive() { - byte[] buffer = new byte[RECV_BUFFER_SIZE]; + byte[] recvBuffer = new byte[RECV_BUFFER_SIZE]; + byte[] msgBuffer = new byte[MSG_BUFFER_SIZE]; + int offset = 0; try { while (ws.State == WebSocketState.Open) { - WebSocketReceiveResult result = await ws.ReceiveAsync(new ArraySegment(buffer), default); + WebSocketReceiveResult result = await ws.ReceiveAsync(new ArraySegment(recvBuffer), default); if (result.MessageType == WebSocketMessageType.Close) { LCLogger.Debug($"Receive Closed: {result.CloseStatus}"); if (ws.State == WebSocketState.CloseReceived) { @@ -98,9 +103,18 @@ namespace LeanCloud.Realtime.Internal.WebSocket { } else { // 拼合 WebSocket Message int length = result.Count; - byte[] data = new byte[length]; - Array.Copy(buffer, data, length); - OnMessage?.Invoke(data); + if (offset + length > msgBuffer.Length) { + // 反序列化数组大小不够,则以 2x 扩充 + byte[] newBuffer = new byte[msgBuffer.Length * 2]; + Array.Copy(msgBuffer, newBuffer, msgBuffer.Length); + msgBuffer = newBuffer; + } + Array.Copy(recvBuffer, 0, msgBuffer, offset, length); + offset += length; + if (result.EndOfMessage) { + OnMessage?.Invoke(msgBuffer, offset); + offset = 0; + } } } } catch (Exception e) { From 31c16cc7e2371aaab4958bb06f25fae2baf58da3 Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 1 Feb 2021 16:57:45 +0800 Subject: [PATCH 4/7] fix: update memory auth data. --- Storage/Storage.Test/UserTest.cs | 4 ++-- Storage/Storage/LCUser.cs | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Storage/Storage.Test/UserTest.cs b/Storage/Storage.Test/UserTest.cs index 7d1ba8b..99f320a 100644 --- a/Storage/Storage.Test/UserTest.cs +++ b/Storage/Storage.Test/UserTest.cs @@ -49,7 +49,7 @@ namespace Storage.Test { Assert.NotNull(current.ObjectId); Assert.IsFalse(current.EmailVerified); Assert.IsFalse(current.MobileVerified); - Assert.AreEqual(current.Mobile, "15101006008"); + Assert.AreEqual(current.Mobile, "15101006007"); } [Test] @@ -70,7 +70,7 @@ namespace Storage.Test { [Test] public async Task RelateObject() { - LCUser user = await LCUser.LoginByMobilePhoneNumber("15101006007", "112358"); + LCUser user = await LCUser.LoginByMobilePhoneNumber("15101006007", "world"); LCObject account = new LCObject("Account"); account["user"] = user; await account.Save(); diff --git a/Storage/Storage/LCUser.cs b/Storage/Storage/LCUser.cs index 4b20305..7a5b1dd 100644 --- a/Storage/Storage/LCUser.cs +++ b/Storage/Storage/LCUser.cs @@ -531,8 +531,8 @@ namespace LeanCloud.Storage { }; try { await Save(); - oriAuthData.Add(authType, data); - AuthData = oriAuthData; + oriAuthData[authType] = data; + UpdateAuthData(oriAuthData); } catch (Exception e) { AuthData = oriAuthData; throw e; @@ -547,13 +547,19 @@ namespace LeanCloud.Storage { try { await Save(); oriAuthData.Remove(authType); - AuthData = oriAuthData; + UpdateAuthData(oriAuthData); } catch (Exception e) { AuthData = oriAuthData; throw e; } } + private void UpdateAuthData(Dictionary authData) { + LCObjectData objData = new LCObjectData(); + objData.CustomPropertyDict["authData"] = authData; + Merge(objData); + } + static async Task Login(Dictionary data) { Dictionary response = await LCApplication.HttpClient.Post>("login", data: data); LCObjectData objectData = LCObjectData.Decode(response); From 46fcf052cfa8800bc752f08f18b6da1cc9b88811 Mon Sep 17 00:00:00 2001 From: oneRain Date: Tue, 2 Feb 2021 12:12:46 +0800 Subject: [PATCH 5/7] chore: field name limitation. --- Storage/Storage/LCObject.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Storage/Storage/LCObject.cs b/Storage/Storage/LCObject.cs index cdbd90f..67bc2dd 100644 --- a/Storage/Storage/LCObject.cs +++ b/Storage/Storage/LCObject.cs @@ -125,7 +125,8 @@ namespace LeanCloud.Storage { if (key.StartsWith("_")) { throw new ArgumentException("key should not start with '_'"); } - if (key == "objectId" || key == "createdAt" || key == "updatedAt") { + if (key == "objectId" || key == "createdAt" || key == "updatedAt" || + key == "className" || key == "ACL") { throw new ArgumentException($"{key} is reserved by LeanCloud"); } LCSetOperation setOp = new LCSetOperation(value); From bb0a7840ec172d216d294b48312836cf95dec52b Mon Sep 17 00:00:00 2001 From: oneRain Date: Tue, 2 Feb 2021 14:35:43 +0800 Subject: [PATCH 6/7] chore --- Storage/Storage/LCObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Storage/Storage/LCObject.cs b/Storage/Storage/LCObject.cs index 67bc2dd..0c302b2 100644 --- a/Storage/Storage/LCObject.cs +++ b/Storage/Storage/LCObject.cs @@ -126,7 +126,7 @@ namespace LeanCloud.Storage { throw new ArgumentException("key should not start with '_'"); } if (key == "objectId" || key == "createdAt" || key == "updatedAt" || - key == "className" || key == "ACL") { + key == "className") { throw new ArgumentException($"{key} is reserved by LeanCloud"); } LCSetOperation setOp = new LCSetOperation(value); From dbe9c4ac5b62cf41655273541da0325b72681853 Mon Sep 17 00:00:00 2001 From: oneRain Date: Tue, 2 Feb 2021 14:38:40 +0800 Subject: [PATCH 7/7] chore --- .../mono_crash.11a6748113.0.json | 724 ------------------ 1 file changed, 724 deletions(-) delete mode 100644 Realtime/Realtime-Unity/mono_crash.11a6748113.0.json diff --git a/Realtime/Realtime-Unity/mono_crash.11a6748113.0.json b/Realtime/Realtime-Unity/mono_crash.11a6748113.0.json deleted file mode 100644 index d03d2ae..0000000 --- a/Realtime/Realtime-Unity/mono_crash.11a6748113.0.json +++ /dev/null @@ -1,724 +0,0 @@ -{ - "protocol_version" : "0.0.6", - "configuration" : { - "version" : "(6.12.0.113) (2020-02/4fdfb5b1fd5)", - "tlc" : "normal", - "sigsgev" : "altstack", - "notifications" : "kqueue", - "architecture" : "amd64", - "disabled_features" : "none", - "smallconfig" : "disabled", - "bigarrays" : "disabled", - "softdebug" : "enabled", - "interpreter" : "enabled", - "llvm_support" : "0", - "suspend" : "hybrid" - }, - "memory" : { - "Resident Size" : "139730944", - "Virtual Size" : "4704305152", - "minor_gc_time" : "0", - "major_gc_time" : "0", - "minor_gc_count" : "0", - "major_gc_count" : "0", - "major_gc_time_concurrent" : "0" - }, - "threads" : [ - { - "is_managed" : false, - "offset_free_hash" : "0x0", - "offset_rich_hash" : "0x0", - "crashed" : false, - "native_thread_id" : "0x70000bfee000", - "thread_info_addr" : "0x7f882d02c000", - "thread_name" : "Finalizer", - "ctx" : { - "IP" : "0x7fff67c69e36", - "SP" : "0x70000bfedeb8", - "BP" : "0x70000bfedf00" - }, - "unmanaged_frames" : [ - { - "is_managed" : "false", - "native_address" : "0x10733ca06", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d8165", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d7e97", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1073a89d0", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67d215fd", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "unregistered" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d8dad", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67d2d109", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67d28b8b", - "native_offset" : "0x00000" - } - - ] - }, - { - "is_managed" : false, - "offset_free_hash" : "0x0", - "offset_rich_hash" : "0x0", - "crashed" : false, - "native_thread_id" : "0x1162a5dc0", - "thread_info_addr" : "0x7f882a80a000", - "thread_name" : "tid_307", - "ctx" : { - "IP" : "0x7fff67c6c882", - "SP" : "0x7ffee8973bf8", - "BP" : "0x7ffee8973c90" - }, - "unmanaged_frames" : [ - { - "is_managed" : "false", - "native_address" : "0x10733ca06", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d8165", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d7e97", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1073a89d0", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67d215fd", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "unregistered" - } -, - { - "is_managed" : "false", - "native_address" : "0x107572ee0", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x10758afc1", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d5084", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d4e8a", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1073020fa", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x10728e1e8", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67b28cc9", - "native_offset" : "0x00000" - } - - ] - }, - { - "is_managed" : true, - "offset_free_hash" : "0x11a6748113", - "offset_rich_hash" : "0x11a6748628", - "crashed" : true, - "native_thread_id" : "0x70000e36a000", - "thread_info_addr" : "0x7f882d258a00", - "thread_name" : "tid_6303", - "ctx" : { - "IP" : "0x7fff67c7033a", - "SP" : "0x70000e362b98", - "BP" : "0x70000e362bc0" - }, - "managed_frames" : [ - { - "is_managed" : "false", - "native_address" : "unregistered" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00015" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x6004287", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x0026a" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x6004487", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x00043" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed4", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00071" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed2", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed1", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x0002b" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x6004286", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x00093" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0xffffffff" - } -, - { - "is_managed" : "false", - "native_address" : "unregistered" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x600447f", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x0003a" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001f2c", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00025" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed4", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00071" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed2", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed1", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x0002b" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x0002a" - } - - ], - "unmanaged_frames" : [ - { - "is_managed" : "false", - "native_address" : "0x10733ca06", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d8165", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d87da", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1073a9a97", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x10734169e", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1073a8d8f", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67d215fd", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "unregistered" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67bf7808", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x107595f67", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x107576def", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1075963fe", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x10759657f", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1075965ba", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x10758ad8e", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d26d1", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d934d", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d6fbc", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x6004287", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x6004487", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed4", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed2", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2f196993", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2f195dfe", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2f195cf7", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2f19892b", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2daa7b05", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2da79304", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2da79250", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2da77d79", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2da76e3e", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff2daff489", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x10e1fdfcc", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x00000", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "181E198A-F674-4D54-82D2-31B9E17B3F9B", - "token" : "0x600447f", - "native_offset" : "0x0", - "filename" : "System.dll", - "sizeofimage" : "0x292000", - "timestamp" : "0xc58d4017", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001f2c", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "true", - "guid" : "58E88B8B-C383-4E07-A237-B0C4D21C89F2", - "token" : "0x6001ed2", - "native_offset" : "0x0", - "filename" : "mscorlib.dll", - "sizeofimage" : "0x472000", - "timestamp" : "0x86058d7a", - "il_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x10729e9d2", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074adf97", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074b4840", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x1074d8ded", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67d2d109", - "native_offset" : "0x00000" - } -, - { - "is_managed" : "false", - "native_address" : "0x7fff67d28b8b", - "native_offset" : "0x00000" - } - - ] -} -] -} \ No newline at end of file