Esempio n. 1
0
 void P2ServerDeleteSocketHander(System.Net.Sockets.Socket soc)
 {
     try
     {
         int           count  = CmdWorkItems.Count;
         CmdWorkItem[] cilist = new CmdWorkItem[count];
         CmdWorkItems.CopyTo(0, cilist, 0, count);
         foreach (CmdWorkItem CI in cilist)
         {
             try
             {
                 CI.WeaveTcpCmd.WeaveDeleteSocketEvent(soc);
             }
             catch (Exception ex)
             {
                 if (WeaveLogEvent != null)
                 {
                     WeaveLogEvent("EventDeleteConnSoc", ex.Message);
                 }
             }
         }
     }
     catch { }
     try
     {
         int           count = weaveOnline.Count;
         WeaveOnLine[] ols   = new WeaveOnLine[count];
         weaveOnline.CopyTo(0, ols, 0, count);
         foreach (WeaveOnLine ol in ols)
         {
             if (ol.Socket.Equals(soc))
             {
                 foreach (CmdWorkItem CI in CmdWorkItems)
                 {
                     try
                     {
                         WeaveExcCmdNoCheckCmdName(0xff, "out|" + ol.Token, ol.Socket);
                         CI.WeaveTcpCmd.Tokenout(ol);
                     }
                     catch (Exception ex)
                     {
                         if (WeaveLogEvent != null)
                         {
                             WeaveLogEvent("Tokenout", ex.Message);
                         }
                     }
                 }
                 weaveOnline.Remove(ol);
                 return;
             }
         }
     }
     catch { }
 }
Esempio n. 2
0
        public void ReloadFlies()
        {
            try
            {
#if !NETSTANDARD2_0
                String[] strfilelist = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "command");
#else
                String[] strfilelist = System.IO.Directory.GetFiles(AppContext.BaseDirectory + "command");
#endif
                foreach (string file in strfilelist)
                {
                    Assembly ab    = Assembly.LoadFile(file);
                    Type[]   types = ab.GetExportedTypes();
                    foreach (Type t in types)
                    {
                        try
                        {
                            if (t.IsSubclassOf(typeof(WeaveTCPCommand)))
                            {
                                CmdWorkItem     ci  = new CmdWorkItem();
                                object          obj = ab.CreateInstance(t.FullName);
                                WeaveTCPCommand Ic  = obj as WeaveTCPCommand;
                                Ic.SetGlobalQueueTable(weaveTable, TcpTokenList);
                                ci.WeaveTcpCmd = Ic;
                                ci.CmdName     = Ic.Getcommand();
                                GetAttributeInfo(Ic, obj.GetType(), obj);
                                CmdWorkItems.Add(ci);
                            }
                        }
                        catch //(Exception ex)
                        { }
                    }
                }
            }
            catch (Exception ex)
            {
                if (WeaveLogEvent != null)
                {
                    WeaveLogEvent("加载异常", ex.Message);
                }
            }
        }
Esempio n. 3
0
 void P2ServerUpdateSocketHander(System.Net.Sockets.Socket soc)
 {
     try
     {
         int           count  = CmdWorkItems.Count;
         CmdWorkItem[] cilist = new CmdWorkItem[count];
         CmdWorkItems.CopyTo(0, cilist, 0, count);
         foreach (CmdWorkItem CI in cilist)
         {
             try
             {
                 CI.WeaveTcpCmd.WeaveUpdateSocketEvent(soc);
             }
             catch (Exception ex)
             {
                 if (WeaveLogEvent != null)
                 {
                     WeaveLogEvent("EventUpdataConnSoc", ex.Message);
                 }
             }
         }
     }
     catch { }
     foreach (WeaveTcpToken token in TcpTokenList)
     {
         string Token = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(1000, 9999);// EncryptDES(clientipe.Address.ToString() + "|" + DateTime.Now.ToString(), "lllssscc");
         if (token.P2Server.Port == ((System.Net.IPEndPoint)soc.LocalEndPoint).Port)
         {
             bool sendok = false;
             if (token.IsToken)
             {
                 if (token.PortType == WeavePortTypeEnum.Bytes)
                 {
                     sendok = token.P2Server.Send(soc, 0xff, token.BytesDataparsing.Get_ByteBystring("token|" + Token + ""));
                 }
                 else
                 {
                     sendok = token.P2Server.Send(soc, 0xff, "token|" + Token + "");
                 }
             }
             else
             {
                 sendok = true;
             }
             if (sendok)
             {
                 WeaveOnLine ol = new WeaveOnLine();
                 ol.Token  = Token;
                 ol.Socket = soc;
                 weaveOnline.Add(ol);
                 foreach (CmdWorkItem cmdItem in CmdWorkItems)
                 {
                     try
                     {
                         WeaveExcCmdNoCheckCmdName(0xff, "in|" + ol.Token, ol.Socket);
                         cmdItem.WeaveTcpCmd.TokenIn(ol);
                     }
                     catch (Exception ex)
                     {
                         if (WeaveLogEvent != null)
                         {
                             WeaveLogEvent("Tokenin", ex.Message);
                         }
                     }
                 }
                 return;
             }
         }
     }
 }