Пример #1
0
        internal static bool RegisterConnectingConnection(TCPConnection conn, int connectTimeout)
        {
            CheckInitStatus();
            lock (interLocker)
            {
                if (forbiddenRegisterConnection)    //-- Unity iOS only.
                {
                    return(false);
                }

                if (connectTimeout <= 0)
                {
                    connectTimeout = globalQuestTimeoutSeconds;
                }

                connectingConnections.Add(conn, GetCurrentSeconds() + connectTimeout);
                allConnections.Add(conn);
            }

            return(true);
        }
Пример #2
0
        private void ConfigConnectedDelegate(TCPConnection conn, ConnectionConnectedDelegate cb, ManualResetEvent finishEvent)
        {
            conn.SetConnectedDelegate((Int64 connectionId, string endpoint, bool connected) =>
            {
                if (cb != null)
                {
                    try
                    {
                        cb(connectionId, endpoint, connected);
                    }
                    catch (Exception ex)
                    {
                        if (errorRecorder != null)
                        {
                            errorRecorder.RecordError("Connected event exception. Remote endpoint: " + endpoint + ".", ex);
                        }
                    }
                }

                SetClientStatus(conn, connected ? ClientStatus.Connected : ClientStatus.Closed);

                finishEvent.Set();
            });
        }