Beispiel #1
0
        public void AddProt(List <WeaveServerPort> listServerPort)
        {
            foreach (WeaveServerPort sp in listServerPort)
            {
                IWeaveTcpBase p2psev = null;
                WeaveTcpToken tt     = new WeaveTcpToken();
                if (sp.PortType == WeavePortTypeEnum.Web)
                {
                    p2psev = new WeaveWebServer();
                    if (sp.Certificate != null)
                    {
                        ((WeaveWebServer)p2psev).Certificate = sp.Certificate;
                    }
                }
                else if (sp.PortType == WeavePortTypeEnum.Json)
                {
                    p2psev = new WeaveP2Server("127.0.0.1");
                }
                else if (sp.PortType == WeavePortTypeEnum.Bytes)
                {
                    p2psev = new WeaveP2Server(WeaveDataTypeEnum.Bytes);
                    if (sp.BytesDataparsing == null)
                    {
                        throw new Exception("BytesDataparsing对象不能是空,请完成对应接口的实现。");
                    }
                    tt.BytesDataparsing          = sp.BytesDataparsing;
                    p2psev.weaveReceiveBitEvent += P2psev_receiveeventbit;
                }
                //else if (sp.PortType == WeavePortTypeEnum.jsonudp)
                //{
                //    p2psev = new WeaveUDPServer(WeaveDataTypeEnum.Json);

                //}
                //else if (sp.PortType == WeavePortTypeEnum.Json)
                //{
                //    p2psev = new WeaveUDPServer("127.0.0.1");
                //}
                else if (sp.PortType == WeavePortTypeEnum.Http)
                {
                    p2psev = new HttpServer(sp.Port);
                }
                p2psev.waveReceiveEvent           += P2ServerReceiveHander;
                p2psev.weaveUpdateSocketListEvent += P2ServerUpdateSocketHander;
                p2psev.weaveDeleteSocketListEvent += P2ServerDeleteSocketHander;
                //   p2psev.NATthroughevent += tcp_NATthroughevent;//p2p事件,不需要使用
                p2psev.Start(Convert.ToInt32(sp.Port));//myI.Parameter[4]是端口号
                tt.PortType = sp.PortType;
                tt.P2Server = p2psev;
                tt.IsToken  = sp.IsToken;
                tt.WPTE     = sp.PortType;
                TcpTokenList.Add(tt);
                P2ServerList.Add(p2psev);
            }
        }
Beispiel #2
0
 void init(WeavePortTypeEnum Wpte)
 {
     if (Wpte == WeavePortTypeEnum.Web)
     {
         p2psev = new WeaveWebServer();
     }
     else if (Wpte == WeavePortTypeEnum.Json)
     {
         p2psev = new WeaveP2Server();
     }
     else if (Wpte == WeavePortTypeEnum.Bytes)
     {
         p2psev = new WeaveP2Server(WeaveDataTypeEnum.Bytes);
     }
 }
Beispiel #3
0
        private void OpenFile(object sender, EventArgs e)
        {
            System.IO.StreamReader sr = new System.IO.StreamReader("port.txt");
            while (!sr.EndOfStream)
            {
                String  str       = sr.ReadLine();
                minForm childForm = new minForm();
                childForm.Name      = str;
                childForm.MdiParent = this;
                childForm.Text      = "端口:" + str.Split(':')[0] + "--类型:" + str.Split(':')[1];
                childForm.Show();
                IWeaveTcpBase wps = null;
                if (str.Split(':')[1] == "socket")
                {
                    wps = new WeaveP2Server();
                }
                if (str.Split(':')[1] == "websocket")
                {
                    wps = new WeaveWebServer();
                }
                if (str.Split(':')[1] == "http")
                {
                    wps = new HttpServer(Convert.ToInt32(str.Split(':')[0]));
                }

                wps.waveReceiveEvent           += Wps_waveReceiveEvent;
                wps.weaveDeleteSocketListEvent += Wps_weaveDeleteSocketListEvent;
                wps.weaveUpdateSocketListEvent += Wps_weaveUpdateSocketListEvent;
                wps.Start(Convert.ToInt32(str.Split(':')[0]));
                //  wps.GetNetworkItemCount();
                WMQMODE wm = new WMQMODE();
                wm.iwtb = wps;
                wm.mf   = childForm;
                listiwtcp.Add(wm);
                listminForm.Add(childForm);
                childForm.listBox1.Items.Add("监听已启动。。。。");
            }
            sr.Close();
            timer1.Start();
            openToolStripMenuItem.Enabled = false;
            LayoutMdi(MdiLayout.TileHorizontal);
        }