Ejemplo n.º 1
0
        private void _server_ClientDataReceived(object sender, ClientDataReceivedEventArgs e)
        {
            string requestHeader = Encoding.UTF8.GetString(e.Data);

            foreach (string line in requestHeader.Split('\n'))
            {
                if (!line.StartsWith("GET"))
                {
                    continue;
                }

                foreach (string part in line.Split(' '))
                {
                    if (!part.StartsWith("/"))
                    {
                        continue;
                    }

                    string streamName = part.Substring(1);

                    if (!_streamers.ContainsKey(streamName))
                    {
                        continue;
                    }

                    _streamers[streamName].AddClient(e.ClientConnection);
                    return;
                }
            }

            _server.DisconnectClient(e.ClientConnection);
        }
Ejemplo n.º 2
0
        private void OnClientDataReceived(object sender, ClientDataReceivedEventArgs e)
        {
            string requestHeader = Encoding.UTF8.GetString(e.Data);

            if (!requestHeader.Contains($"GET {ServerUrl}"))
            {
                // TODO: 404 Error Message
                _server.DisconnectClient(e.ClientConnection);
                return;
            }

            _streamer.AddClient(e.ClientConnection);
        }