Comments (3)
Hey @Starless-Sky Thanks for reporting this. I've confirmed the behaviour and the value of the callback is indeed always true
. This value comes directly from WebsocketSharp (WS#). I've even tried to use whats on the master branch of WS# and this behaviour still persists.
There are two behaviours to note:
- OnSuccess / OnError callbacks that are passed into the
Send()
method. - OnDisconnect / Global OnError.
OnSuccess / OnError callbacks
On the Unity Editor, Android and iOS these are not invoked when the client has disconnected. The reason for this is that there is a buffer in the underlying .net Socket object called SendBufferSize
. The default size of SendBufferSize
on the Unity Editor is 131328
and on Android is 6291456
(iOS is unknown). When sending a message while disconnected, the message is buffered up and released only when you are reconnected to the network.
I've tried setting the SendBufferSize
to really small values (0
, 1
and 128
) but they have various undesired effects for both normal and disconnected states (for instance, in iOS, once the buffer fills up, the app crashes and never comes back up again).
We've spoken internally and have decided to leave the default values here. This means that in a situation where disconnection happens, neither supplied callbacks are invoked. Further details below.
OnDisconnect / Global OnError.
This is different on the three tested platforms. Under the test condition (connected to the server, and manually disconnected), the observed behaviour is as follows:
- On Unity Editor, neither OnDisconnect nor OnError are invoked.
- On Android, OnDisconnect is invoked immediately after disconnecting from the network. OnError is also called in this situation.
- On iOS, OnDisconnect is invoked after a couple of seconds but the OnError is not invoked.
I've tried digging for more information as to why this behaviour is different but sadly I've not reached any conclusions.
Therefore, I've concluded from my research that this is a platform limitation, and on Unity Editor it is probably a limitation/bug in Mono/UnityEngine.
Given that this behaves relatively well on end user devices, we'll leave the functionality as it is and mention this caveat in the Unity documentation.
I'll close this ticket now, but feel free to reopen if you have more information about this.
from nakama-unity.
@mofirouz so can we consider the SendAsync function will always return completed == true to indicate the server/receiver has received the message/data no matter whether it's sent successfully or no?
from nakama-unity.
@chuidifly The SDK was redesigned since this issue was created. It would be good to discuss your questions on the forums.
from nakama-unity.
Related Issues (20)
- Unity - Investigate whether copying of package for asset store release process generates new GUIDs HOT 1
- Unity - [WebGL] SOCKET_REF_MAP.has is not a function HOT 2
- IOS 15 Crash HOT 1
- Could you please provide original C# code for nakama.DLL? HOT 12
- `HttpRequestAdapter` and `WebSocketAdapter` don't connect properly over local network on iOS
- Dont get data of leaderboard HOT 9
- Illegal Byte Sequence during auth when path has chinese characters in it (mono issue) HOT 1
- UnityWebRequestAdapter doesn't write logs to ILogger HOT 1
- Storage write rejected - version check failed HOT 5
- SocketException: mono-io-layer-error (61) on iOS device for AuthenticateDeviceAsync HOT 1
- Imatch Presences is empty HOT 1
- Connect to database HOT 2
- Use database and redis HOT 2
- The document on the official website has not been updated HOT 3
- C# / Unity - [BUG] Client does not get return from server API call HOT 2
- [Ehancement] Open-Source Nakama.dll - Plugins HOT 1
- Doesn't support leaderboard rank counts yet HOT 1
- Trouble with Socket.AddMatchmakerAsync in Nakama HOT 1
- IEnumerable<IApiStorageObject>' does not contain a definition for 'Any' and no accessible extension method 'Any' accepting a first argument of type 'IEnumerable<IApiStorageObject>' could be found (are you missing a using directive or an assembly reference?) HOT 1
- MacOS support ? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nakama-unity.