public DequeueAsyncResult(MakeConnection poll, PollingDuplexSession session, TimeSpan timeout, AsyncCallback callback, object state) { this.AsyncState = state; this.Callback = callback; this.Session = session; this.Poll = poll; this.Timeout = timeout; this.Tags = new RdlTagCollection(); }
public IAsyncResult BeginMakeConnect(MakeConnection poll, AsyncCallback callback, object state) { Logger.LogDebug("SERVER: BeginMakeConnect on Thread [ {0} ]", Thread.CurrentThread.ManagedThreadId); IClient client; Game.Server.Clients.TryGetClient(poll.Address, out client); return(new HeartbeatAsyncResult(poll, client, PollTimeout, callback, state)); }
public List <Product> getListProduct(Product_Detail similar, int orderby, int color) { //Tao danh sach List <Product> ds = new List <Product>(); //Cau lenh truy van string conds = MakeConnection.createCondition(similar); string sqlSelect = "SELECT * FROM dbo.product left join dbo.category on category.category_id = product.category_id "; if (color == 1) { sqlSelect += "left join dbo.product_detail on product.product_id=product_detail.product_id "; } if (conds != "") { sqlSelect += "WHERE " + conds; } sqlSelect += " ORDER BY "; switch (orderby) { case 1: sqlSelect += "product.product_id ASC "; break; case 2: sqlSelect += "product.price ASC "; break; case 3: sqlSelect += "product.price DESC "; break; case 4: sqlSelect += "product.product_id DESC "; break; } //sqlSelect += " LIMIT 3 "; //Mo cong ket noi conn.Open(); //Thuc thi cau lenh SqlCommand cmd = new SqlCommand(sqlSelect, conn); //Doc du lieu tren table trong sql SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { Product p = new Product(); p.product_id = (int)rd["product_id"]; p.product_name = (string)rd["product_name"]; p.category_id = (int)rd["category_id"]; p.descriptions = (string)rd["descriptions"]; p.image = (string)rd["image"]; p.price = (int)rd["price"]; ds.Add(p); } //Dong bo quan ly ket noi conn.Close(); return(ds); }
public IAsyncResult BeginMakeConnect(MakeConnection poll, AsyncCallback callback, object state) { Logger.LogDebug("SERVER: BeginMakeConnect {0}", poll.Address); var client = Game.Server.Clients.Where(c => c.Address == poll.Address).FirstOrDefault(); PollingDuplexSession session = null; if (client != null) { session = new PollingDuplexSession(client.Address, client.SessionId.ToString()); } else { session = new PollingDuplexSession(poll.Address, String.Empty); } var ar = new DequeueAsyncResult(poll, session, _pollTimeout, callback, state); ThreadPool.QueueUserWorkItem(StartMessageRead, ar); return(ar); }
public HeartbeatAsyncResult(MakeConnection poll, IClient client, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.Poll = poll; this.Timeout = timeout; this.Tags = new RdlTagCollection(); this.Client = client; if (client != null) { this.SessionId = client.SessionId.ToString(); } MethodCall method = HeartbeatAsyncResult.PollClient; method.BeginInvoke(this.Client, this.Timeout, (ar) => { var tags = method.EndInvoke(ar); var result = ar.AsyncState as HeartbeatAsyncResult; result.Tags.AddRange(tags); result.Complete(ar.CompletedSynchronously); }, this); }