Esempio n. 1
0
        public void Add(Unit unit)
        {
            int id = getSeq();

            unit.Id = id;
            addUnits.Put(unit);
        }
Esempio n. 2
0
    public void WriteLog(string msg, int lv)
    {
        if (Application.isMobilePlatform)
        {
            return;
        }
        Log log = new Log(msg, lv);

        logs.Put(log);
    }
Esempio n. 3
0
 private void Run(DateTime runtime)
 {
     foreach (Unit unit in units.Values)
     {
         if (!unit.IsValid)
         {
             removes.Put(unit);
             continue;
         }
         unit.update(runtime);
     }
 }
Esempio n. 4
0
 internal virtual void AddToQueue(CleanupQueue.PathDeletionContext[] contexts)
 {
     foreach (CleanupQueue.PathDeletionContext context in contexts)
     {
         try
         {
             queue.Put(context);
         }
         catch (Exception)
         {
         }
     }
 }
Esempio n. 5
0
 public void OnUnitCrt(common.game.battle.engine.unit.Unit unit)
 {
     adds.Put(unit);
 }
Esempio n. 6
0
 /// <summary>
 /// 动作输入
 /// </summary>
 /// <param name="action"></param>
 public void Cmd(IAction action)
 {
     actions.Put(action);
 }
Esempio n. 7
0
        public void HttpAsyncEvent(Msg msg)
        {
            if (msg == null)
            {
                return;
            }
            byte[]         data      = encoder.encode(msg);
            HttpWebRequest myRequest = null;
            Stream         stream    = null;

            try
            {
                // 发送请求
                myRequest                 = (HttpWebRequest)WebRequest.Create(url);
                myRequest.Timeout         = 30000;
                myRequest.KeepAlive       = false;
                myRequest.CookieContainer = myCookie;
                myRequest.Method          = "POST";
                myRequest.ContentLength   = data.Length;
                stream = myRequest.GetRequestStream();
                stream.Write(data, 0, data.Length);
                stream.Flush();
                // 获得回复
                HttpWebResponse myResponse     = (HttpWebResponse)myRequest.GetResponse();
                Stream          responseStream = myResponse.GetResponseStream();
                HttpStatusCode  code           = myResponse.StatusCode;
                if (code == HttpStatusCode.OK)
                {
                    byte[]   temp   = new byte[128];
                    int      i      = 0;
                    IoBuffer buffer = new IoBuffer();
                    do
                    {
                        i = responseStream.Read(temp, 0, 128);
                        if (i > 0)
                        {
                            buffer.Write(temp, 0, i);
                        }
                    } while (i > 0);
                    responseStream.Close();
                    int    len   = buffer.Length;
                    byte[] datas = new byte[len];
                    buffer.Read(datas, 0, len);

                    //单包模型
                    Msg revMsg = decoder.DeCode(datas);
                    if (logReport != null)
                    {
                        logReport.OnLogReport("rev http rsp,cmd:" + revMsg.Cmd + " rsCode:" + revMsg.GetParam(BaseCodeMap.BaseParam.RS_CODE));
                    }
                    mDataPackets.Put(new RevEvent(this, revMsg));
                }
                else
                {
                    if (logReport != null)
                    {
                        logReport.OnWarningReport("http cmd:" + msg.Cmd + " fail,code:" + code);
                    }
                    msg.AddParam(BaseCodeMap.BaseParam.RS_CODE, BaseCodeMap.BaseRsCode.TIME_OUT);
                    mDataPackets.Put(new TimeOutEvent(this, msg));
                }

                return;
            }
            catch (Exception ex)
            {
                if (logReport != null)
                {
                    logReport.OnWarningReport("http cmd:" + msg.Cmd + " ex:" + ex.ToString());
                }
                mDataPackets.Put(new TimeOutEvent(this, msg));
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
Esempio n. 8
0
 public void Trigger(NetEvent netEvent)
 {
     events.Put(netEvent);
 }
 public void TestPut()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(SIZE);
         for (int i = 0; i < SIZE; ++i)
         {
              q.Put(i.ToString());
              Assert.IsTrue(q.Contains(i.ToString()));
          }
          Assert.AreEqual(0, q.RemainingCapacity());
     }
     catch (Exception)
     {
         UnexpectedException();
     }
 }
 public void TestPutNull()
 {
     try
     {
         LinkedBlockingQueue<String> q = new LinkedBlockingQueue<String>(SIZE);
         q.Put(null);
         ShouldThrow();
     }
     catch (NullReferenceException)
     {
     }
     catch (Exception)
     {
         UnexpectedException();
     }
 }