Example #1
0
        public TcpInputConnector(string ipAddressAndPort, IProtocolFormatter protocolFormatter, ISecurityFactory securityFactory,
                                 int sendTimeout,
                                 int receiveTimeout,
                                 int sendBuffer,
                                 int receiveBuffer,
                                 bool reuseAddressFlag,
                                 int maxAmountOfConnections)
        {
            using (EneterTrace.Entering())
            {
                Uri aUri;
                try
                {
                    aUri = new Uri(ipAddressAndPort);
                }
                catch (Exception err)
                {
                    EneterTrace.Error(ipAddressAndPort + ErrorHandler.InvalidUriAddress, err);
                    throw;
                }

                int aPort = (aUri.Port < 0) ? 0 : aUri.Port;
                myTcpListenerProvider   = new TcpListenerProvider(IPAddress.Parse(aUri.Host), aPort, reuseAddressFlag, maxAmountOfConnections);
                myProtocolFormatter     = protocolFormatter;
                mySecurityStreamFactory = securityFactory;
                mySendTimeout           = sendTimeout;
                myReceiveTimeout        = receiveTimeout;
                mySendBuffer            = sendBuffer;
                myReceiveBuffer         = receiveBuffer;

                // Check if protocol encodes open and close messages.
                myProtocolUsesOpenConnectionMessage = myProtocolFormatter.EncodeOpenConnectionMessage("test") != null;
            }
        }
        public WebSocketInputConnector(string wsUriAddress, IProtocolFormatter protocolFormatter, ISecurityFactory securityFactory, int sendTimeout, int receiveTimeout,
                                       bool reuseAddressFlag,
                                       int maxAmountOfConnections)
        {
            using (EneterTrace.Entering())
            {
                Uri aUri;
                try
                {
                    aUri = new Uri(wsUriAddress);
                }
                catch (Exception err)
                {
                    EneterTrace.Error(wsUriAddress + ErrorHandler.InvalidUriAddress, err);
                    throw;
                }

                myProtocolFormatter           = protocolFormatter;
                myListener                    = new WebSocketListener(aUri, securityFactory);
                myListener.ReuseAddress       = reuseAddressFlag;
                myListener.MaxAmountOfClients = maxAmountOfConnections;

                mySendTimeout    = sendTimeout;
                myReceiveTimeout = receiveTimeout;

                // Check if protocol encodes open and close messages.
                myProtocolUsesOpenConnectionMessage = myProtocolFormatter.EncodeOpenConnectionMessage("test") != null;
            }
        }