/// <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()); }
/// <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); }
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(); } }
public bool IsInContainer(ISecurityContainer container) { throw new InvalidOperationException("The STARTUP user is not a member of any container (group or organizational unit)."); }
public bool IsInContainer(ISecurityContainer container) { throw new NotImplementedException(); }
public bool IsInContainer(ISecurityContainer container) { return(SecurityHandler.IsInGroup(this.Id, container.Id)); }
public bool IsInContainer(ISecurityContainer container) { return(Security.IsInGroup(container.Id)); }
public bool IsInContainer(ISecurityContainer container) { return PermissionEvaluator.Instance.IsInGroup(this._userId, container.Id); }
public bool IsInContainer(ISecurityContainer container) { throw new InvalidOperationException("The SYSTEM user is not a member of any container (group or organizational unit)."); }
public bool IsInContainer(ISecurityContainer container) { return Security.IsInGroup(container.Id); }