コード例 #1
0
ファイル: WebSocketServer.cs プロジェクト: vbguyny/Fleck
        public void Dispose()
        {
            // mjb
            if ((AccessPolicyServer != null) && (FlashAccessPolicyEnabled))
            {
                AccessPolicyServer.Stop();
                AccessPolicyServer = null;
            }

            ListenerSocket.Dispose();
        }
コード例 #2
0
ファイル: RequestParser.cs プロジェクト: vbguyny/Fleck
        // mjb public static WebSocketHttpRequest Parse(byte[] bytes, string scheme)
        public static WebSocketHttpRequest Parse(byte[] bytes, string scheme, AccessPolicyServer AccessPolicyServer, ISocket clientSocket)
        {
            var body = Encoding.UTF8.GetString(bytes);
            Match match = _regex.Match(body);

            // mjb
            //if (!match.Success)
            //    return null;
            if (!match.Success)
            {
                if (body == "<policy-file-request/>\0")
                {
                    if (AccessPolicyServer != null)
                    {
                        AccessPolicyServer.SendResponse(clientSocket.Socket);
                    }
                }

                return null;
            }

            var request = new WebSocketHttpRequest
            {
                Method = match.Groups["method"].Value,
                Path = match.Groups["path"].Value,
                Body = match.Groups["body"].Value,
                Bytes = bytes,
                Scheme = scheme
            };

            var fields = match.Groups["field_name"].Captures;
            var values = match.Groups["field_value"].Captures;
            for (var i = 0; i < fields.Count; i++)
            {
                var name = fields[i].ToString();
                var value = values[i].ToString();
                request.Headers[name] = value;
            }

            return request;
        }
コード例 #3
0
ファイル: WebSocketServer.cs プロジェクト: vbguyny/Fleck
        public void Start(Action<IWebSocketConnection> config)
        {
            var ipLocal = new IPEndPoint(IPAddress.Any, Port);
            ListenerSocket.Bind(ipLocal);
            ListenerSocket.Listen(100);
            FleckLog.Info("Server started at " + Location);
            if (_scheme == "wss")
            {
                if (Certificate == null)
                {
                    FleckLog.Error("Scheme cannot be 'wss' without a Certificate");
                    return;
                }
            }
            ListenForClients();
            _config = config;

            // mjb
            if (AccessPolicyServer == null)
            {
                AccessPolicyServer = new AccessPolicyServer(IPAddress.Any, string.Empty, Port);

                if (FlashAccessPolicyEnabled)
                {
                    AccessPolicyServer.Start();
                }
            }
        }