Esempio n. 1
0
        protected void p2psev_EventDeleteConnSoc(System.Net.Sockets.Socket soc)
        {
            try
            {
                ConnObj[] coobjs = new ConnObj[0];
                int       count  = 0;
                try
                {
                    count  = ConnObjlist.Count;
                    coobjs = new ConnObj[count];
                    ConnObjlist.CopyTo(coobjs);
                }
                catch { }
                //ThreadList<ConnObj> coobjs = ConnObjlist.Clone();
                foreach (ConnObj coob in coobjs)
                {
                    if (coob != null)
                    {
                        if (coob.Soc.Equals(soc))
                        {
                            ConnObjlist.Remove(coob);
                            try
                            {
                                count = CommandItemS.Count;
                                CommandItem[] comItems = new CommandItem[count];
                                CommandItemS.CopyTo(0, comItems, 0, count);

                                foreach (CommandItem ci in comItems)
                                {
                                    ci.Client[0].send(0xff, "out|" + coob.Token);
                                }
                            }
                            catch { }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (EventMylog != null)
                {
                    EventMylog("加载异常", ex.Message);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 这里写接收到内容后,转发
        /// </summary>
        /// <param name="command"></param>
        /// <param name="text"></param>
        protected void V_receiveServerEvent(byte command, string text)
        {
            _baseModel _0x01 = Newtonsoft.Json.JsonConvert.DeserializeObject <_baseModel>(text);

            try
            {
                int       count  = ConnObjlist.Count;
                ConnObj[] coobjs = new ConnObj[count];
                ConnObjlist.CopyTo(0, coobjs, 0, count);
                foreach (ConnObj coob in coobjs)
                {
                    if (coob != null)
                    {
                        if (coob.Token == _0x01.Token)
                        {
                            p2psev.send(coob.Soc, command, text);
                            return;
                        }
                    }
                }
            }
            catch (Exception ex) { EventMylog("转发", ex.Message); }
        }