示例#1
0
        internal void SendCommand(byte[] commandBytes, bool checkConnected)
        {
            if (_perfStatsColl.IsEnabled)
            {
                _perfStatsColl.IncrementClientRequestsPerSecStats(1);
            }


            byte[] dataWithSize = new byte[commandBytes.Length + MessageHeader];
            byte[] lengthBytes  = HelperFxn.ToBytes(commandBytes.Length.ToString());

            Array.Copy(lengthBytes, 0, dataWithSize, 0, lengthBytes.Length);
            Array.Copy(commandBytes, 0, dataWithSize, MessageHeader, commandBytes.Length);


            if (SupportDualSocket)
            {
                Socket selectedSocket = _primaryClient;
                lock (_socketSelectionMutex)
                {
                    if (!_usePrimary)
                    {
                        selectedSocket = _secondaryClient;
                    }
                    _usePrimary = !_usePrimary;
                }

                AssureSend(dataWithSize, selectedSocket, checkConnected);
            }
            else
            {
                AssureSend(dataWithSize, _primaryClient, checkConnected);
            }
        }
示例#2
0
        internal void SendCommand(byte[] commandBytes, bool checkConnected)
        {
            if (_perfStatsColl.IsEnabled)
            {
                _perfStatsColl.IncrementClientRequestsPerSecStats(1);
            }

            if (DoNaggling)
            {
                _msgQueue.add(commandBytes);
            }
            else
            {
                if (SupportDualSocket)
                {
                    Socket selectedSocket = _primaryClient;

                    lock (_socketSelectionMutex)
                    {
                        if (!_usePrimary)
                        {
                            selectedSocket = _secondaryClient;
                        }
                        _usePrimary = !_usePrimary;
                    }

                    AssureSend(commandBytes, selectedSocket, checkConnected);
                }
                else
                {
                    AssureSend(commandBytes, _primaryClient, checkConnected);
                }
            }
        }