예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebSocketServer"/> class.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="host">The host.</param>
        /// <param name="port">The port.</param>
        /// <param name="dependencyUtility">The dependency utility.</param>
        /// <param name="listenerThreads">The listener threads.</param>
        /// <param name="clientThreadMultiplier">The client thread multiplier.</param>
        public WebSocketServer(string id, string host, int port, IDependencyUtility dependencyUtility = null, int listenerThreads = 1, int clientThreadMultiplier = 3)
        {
            Id   = id;
            Host = host;
            Port = port;

            _listenerThreads        = listenerThreads;
            _clientThreadMultiplier = clientThreadMultiplier;
            _dependencyUtility      = dependencyUtility ?? new DependencyUtility();

            _logger = _dependencyUtility.Resolve <ILogger>() ??
                      _dependencyUtility.Register <ILogger>(new Logger());

            _securityContainer = _dependencyUtility.Resolve <ISecurityContainer>() ??
                                 _dependencyUtility.Register <ISecurityContainer>(new SecurityContainer(null, SslProtocols.None, false, false, false));

            _clientHandler = _dependencyUtility.Resolve <ITcpHandler>() ??
                             _dependencyUtility.Register <ITcpHandler>(new TcpHandler(IPAddress.Parse(Host), Port));

            _connectionManager = _dependencyUtility.Resolve <IWebSocketConnectionManager>() ??
                                 _dependencyUtility.Register <IWebSocketConnectionManager>(new WebSocketConnectionManager(_dependencyUtility));

            _threadHelper = _dependencyUtility.Resolve <IThreadHelper>() ??
                            _dependencyUtility.Register <IThreadHelper>(new ThreadHelper());

            _routeTable = _dependencyUtility.Resolve <IRouteTable>() ??
                          _dependencyUtility.Register <IRouteTable>(BuildRouteTable());
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebSocketConnection" /> class.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="dependencyUtility">The dependency utility.</param>
        public WebSocketConnection(TcpClient client, IDependencyUtility dependencyUtility)
        {
            _client            = client;
            _dependencyUtility = dependencyUtility ?? new DependencyUtility();
            _securityContainer = _dependencyUtility.Resolve <ISecurityContainer>() ?? new SecurityContainer(null, SslProtocols.None, false, false, false);
            _routeTable        = _dependencyUtility.Resolve <IRouteTable>() ?? new RouteTable();
            _threadHelper      = _dependencyUtility.Resolve <IThreadHelper>() ?? new ThreadHelper();
            _logger            = _dependencyUtility.Resolve <ILogger>() ?? new Logger();

            _frameReader = new WebSocketFrameReader(_dependencyUtility);
            _frameWriter = new WebSocketFrameWriter(_dependencyUtility);
        }
예제 #3
0
파일: Program.cs 프로젝트: systemidx/Loki
        static void Main(string[] args)
        {
            //Create our dependency utility
            IDependencyUtility dependencyUtility = new DependencyUtility();

            //Create our security container
            ISecurityContainer securityContainer = GenerateSecurityContainer();

            //Register dependencies
            dependencyUtility.Register <ISecurityContainer>(securityContainer);

            //Set port and host
            int       port = Convert.ToInt32(1337);
            IPAddress host = IPAddress.Parse("0.0.0.0");

            //Start the server
            using (IServer server = new Server.WebSocketServer("MyServerName", host, port, dependencyUtility))
            {
                //Start listening and blocking the main thread
                server.Run();
            }
        }
예제 #4
0
 public bool IsInContainer(ISecurityContainer container)
 {
     throw new InvalidOperationException("The STARTUP user is not a member of any container (group or organizational unit).");
 }
예제 #5
0
 public bool IsInContainer(ISecurityContainer container)
 {
     throw new NotImplementedException();
 }
예제 #6
0
 public bool IsInContainer(ISecurityContainer container)
 {
     return(SecurityHandler.IsInGroup(this.Id, container.Id));
 }
예제 #7
0
파일: User.cs 프로젝트: pchaozhong/FlexNet
 public bool IsInContainer(ISecurityContainer container)
 {
     return(Security.IsInGroup(container.Id));
 }
예제 #8
0
 public bool IsInContainer(ISecurityContainer container)
 {
     return PermissionEvaluator.Instance.IsInGroup(this._userId, container.Id);
 }
예제 #9
0
 public bool IsInContainer(ISecurityContainer container)
 {
     throw new InvalidOperationException("The SYSTEM user is not a member of any container (group or organizational unit).");
 }
예제 #10
0
파일: User.cs 프로젝트: jhuntsman/FlexNet
 public bool IsInContainer(ISecurityContainer container)
 {
     return Security.IsInGroup(container.Id);
 }