Пример #1
0
        private void SniffSessionSink(MiniWebServer Sender, HTTPSession s)
        {
            if (OnSniff != null)
            {
                s.OnSniff += new HTTPSession.SniffHandler(SniffSessionSink2);
            }
            else
            {
                if (OnSniffPacket == null)
                {
                    Sender.OnSession -= new MiniWebServer.NewSessionHandler(SniffSessionSink);
                }
            }

            if (OnSniffPacket != null)
            {
                s.OnSniffPacket += new HTTPSession.ReceiveHandler(SniffSessionSink3);
            }
        }
Пример #2
0
        private void NewDeviceInterface(NetworkInfo sender, IPAddress ip)
        {
            try
            {
                //String tmp = ip.ToString();

                MiniWebServer WebServer;
                WebServer = new MiniWebServer(new IPEndPoint(ip, UseThisPort));
                if ((this.OnSniff != null) || (this.OnSniffPacket != null))
                    WebServer.OnSession += new MiniWebServer.NewSessionHandler(SniffSessionSink);

                WebServer.OnReceive += new MiniWebServer.HTTPReceiveHandler(HandleWebRequest);
                WebServer.OnHeader += new MiniWebServer.HTTPReceiveHandler(HandleHeaderRequest);
                WebServerTable[ip.ToString()] = WebServer;
                SendNotify(ip);
            }
            catch (SocketException ex)
            {
                // Cannot bind to this IPAddress, so just ignore
                OpenSource.Utilities.EventLogger.Log(ex);
                OpenSource.Utilities.EventLogger.Log(ex, "UPnPDevice: " + this.FriendlyName + " @" + ip.ToString());
                //				System.Windows.Forms.MessageBox.Show(ex.ToString(),"UPnPDevice: " + this.FriendlyName+" @"+ip.ToString());
            }
        }
Пример #3
0
        private void NewCPInterface(NetworkInfo sender, IPAddress ip)
        {
            lock (typeof(UPnPDevice))
            {
                if (CPWebServerTable.ContainsKey(ip.ToString()) == false)
                {
                    MiniWebServer ws = new MiniWebServer(new IPEndPoint(ip, 0));
                    ws.OnReceive += new MiniWebServer.HTTPReceiveHandler(HandleWebRequest);
                    ws.OnHeader += new MiniWebServer.HTTPReceiveHandler(HandleHeaderRequest);
                    CPWebServerTable[ip.ToString()] = ws;
                }
                else
                {
                    if (CP_RegisteredInterfaces.ContainsKey(ip.ToString()) == false)
                    {
                        CP_RegisteredInterfaces[ip.ToString()] = true;
                        ((MiniWebServer)CPWebServerTable[ip.ToString()]).OnReceive += new MiniWebServer.HTTPReceiveHandler(HandleWebRequest);
                        ((MiniWebServer)CPWebServerTable[ip.ToString()]).OnHeader += new MiniWebServer.HTTPReceiveHandler(HandleHeaderRequest);
                    }
                }

            }
        }
Пример #4
0
        private void ManualNewDeviceInterface(IPAddress ip, int Port)
        {
            //String tmp = ip.ToString();
            MiniWebServer WebServer = new MiniWebServer(new IPEndPoint(ip, Port));
            if ((this.OnSniff != null) || (this.OnSniffPacket != null))
                WebServer.OnSession += new MiniWebServer.NewSessionHandler(SniffSessionSink);

            WebServer.OnReceive += new MiniWebServer.HTTPReceiveHandler(HandleWebRequest);
            WebServer.OnHeader += new MiniWebServer.HTTPReceiveHandler(HandleHeaderRequest);
            WebServerTable[ip.ToString()] = WebServer;
            SendNotify(ip);
        }
Пример #5
0
 private void ajax_OnSession(MiniWebServer sender, HTTPSession session)
 {
     session.OnReceive += new OpenSource.UPnP.HTTPSession.ReceiveHandler(ajax_OnReceive);
 }
Пример #6
0
        public MainForm(string[] args)
        {
            //
            // Required for Windows Form Designer support
            //
            MediaResource.AUTOMAPFILE = "file://";
            InitializeComponent();

            //this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width + Screen.PrimaryScreen.WorkingArea.Left;
            //this.Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height + Screen.PrimaryScreen.WorkingArea.Top;
            //this.SetClientSizeCore(this.BackgroundImage.Width-1,this.BackgroundImage.Height-1);

            blueProgressPictureBox.Bounds = greenProgressPictureBox.Bounds;
            blueVolumeBar.Bounds = greenVolumeBar.Bounds;

            Bitmap b = new Bitmap(this.BackgroundImage, this.ClientSize);
            Graphics g = Graphics.FromImage(b);
            g.DrawImage(this.BackgroundImage, new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height), 0, 0, this.BackgroundImage.Width, this.BackgroundImage.Height, GraphicsUnit.Pixel);
            this.BackgroundImage = b;

            this.TopMost = onTopMenuItem.Checked;

            foreach (string a in args)
            {
                if (a == "/NOPIPELINE")
                {
                    HTTPRequest.PIPELINE = false;
                }
                else
                    if (a == "/DEBUG")
                    {
                        OpenSource.Utilities.InstanceTracker.Enabled = true;
                        OpenSource.Utilities.InstanceTracker.Display();
                        OpenSource.Utilities.EventLogger.Enabled = true;
                        OpenSource.Utilities.EventLogger.ShowAll = true;
                    }
                    else
                        if (a == "/NOCHUNK")
                        {
                            HTTPSession.CHUNK_ENABLED = false;
                        }
                if (a.StartsWith("/AJAX:"))
                {
                    IPEndPoint ep = new IPEndPoint(IPAddress.Any, int.Parse(a.Substring(a.IndexOf(":") + 1)));
                    ajax = new MiniWebServer(ep);
                    ajax.OnSession += new OpenSource.UPnP.MiniWebServer.NewSessionHandler(ajax_OnSession);
                }
            }
        }