public FrameMergeResponse MergeFrame(Frame frame) { ThrowIfEnded(); lock (MergeLock) { if (Opcode == 0 && frame.Opcode == 0) { return(FrameMergeResponse.ContinuationOnNoOpcode); } if (Opcode != 0 && frame.Opcode != 0) { return(FrameMergeResponse.OpcodeOnNonFin); } if (frame.Opcode != 0) { Opcode = frame.Opcode; } DataQueue.Enqueue(frame.Payload); DataLength += frame.PayloadLength; if (frame.FIN) { Deflate(); } } return(FrameMergeResponse.Valid); }
/// <summary> /// Sends a request to change data into the database queue. Processing is asynchronous /// and you cannot reliably retrieve the data directly from the database immediately afterwards. /// However, data in the cache will be up to date as soon as a value is changed. /// </summary> public void SubmitDataChange(DatabaseAction action) { if (action == null) { throw new ArgumentNullException(nameof(action)); } if (action.Data == null) { throw new ArgumentNullException(nameof(action.Data)); } var actionType = action.Action; foreach (var item in action.Data) { if (actionType == DatabaseActionType.Insert || actionType == DatabaseActionType.Update) { SetIntoCache(item.GetType(), GetEntityKey(item), item); } else if (actionType == DatabaseActionType.Delete) { DeleteFromCache(item.GetType(), GetEntityKey(item)); } } DataQueue.Enqueue(action); }
public void Simulate() { Control.UseNativeMKL(); var ini = new Initialization() { InitialPositionX = Plane.Position[0], InitialPositionY = Plane.Position[1], InitialPositionZ = Plane.Position[2], InitialAttitudePhi = Plane.Phi, InitialAttitudePsi = Plane.Psi, InitialAttitudeTheta = Plane.Theta }; var conf = new HistoryDemo.Entities.Configuration() { GuidanceConfig = (HistoryDemo.Entities.GuidanceConfig)Configuration.GuidanceController }; DataSendTimer.Start(); while ((Plane.Position[2] - Ship.Position[2]) < 0) { SingleStep(); if (step_count % 50 == 0) { DataQueue.Enqueue(Plane.Alpha); } } Console.WriteLine(step_count); //Record.SaveToDatabase(ini, conf); }
public static void Main(string[] args) { Logger.Info("tcp server program on running... "); Init(); while (true) { try { Console.WriteLine("please input your request package"); var requestPackage = Console.ReadLine(); if (requestPackage != "") { var bytes = StringHelper.HexStringToBytes(requestPackage); DataQueue.Enqueue(bytes); } } catch (Exception ex) { Logger.Error(ex.Message); break; } } Console.Read(); }
static void tcpclient_OnReceivedData(object sender, TcpClient.ReceivedDataEventArgs e) { TcpClient tcp = sender as TcpClient; //写入接收数据队列 lock (DataQueue) { DataQueue.Enqueue(Encoding.UTF8.GetString(e.RevData)); } }
public void QueueData(byte[] data) { if (!Started) { throw new InvalidOperationException("Unable to queue element: Queue processing is not running"); } Logger.Trace("Queue new element {0}", data.GetHashCode()); DataQueue.Enqueue(data); DataAvailableEvent.Set(); }
/// <summary> /// 从源HTML中解析数据到队列 /// </summary> public override void ResolveDataInQueue() { if (_tables == null) { _tables = TableHelper.ResolveTables(SourceHtml); } foreach (var tb in _tables) { //将解释出来的TableDesc加入数据队列 DataQueue.Enqueue(tb); } }
/// <summary> /// Sends a request to change data into the queue. Processing is asynchronous /// and you cannot reliably retrieve the data directly from the database immediately afterwards. /// However, data in the cache will be up to date as soon as a value is changed. /// </summary> /// <param name="data">The data to submit for processing</param> /// <param name="actionType">The type (Insert, Update, Delete, etc.) of change to make.</param> public void SubmitDataChange(IEntity data, DatabaseActionType actionType) { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (actionType == DatabaseActionType.Insert || actionType == DatabaseActionType.Update) { SetIntoCache(data.GetType(), GetEntityKey(data), data); } else if (actionType == DatabaseActionType.Delete) { DeleteFromCache(data.GetType(), GetEntityKey(data)); } DataQueue.Enqueue(new DatabaseAction(data, actionType)); }
/// <summary> /// Sends a request to change data into the queue. Processing is asynchronous /// and you cannot reliably retrieve the data directly from the database immediately afterwards. /// However, data in the cache will be up to date as soon as a value is changed. /// </summary> /// <param name="data">The data to submit for processing</param> /// <param name="actionType">The type (Insert, Update, Delete, etc.) of change to make.</param> public static void SubmitDataChange <T>(T data, DatabaseActionType actionType) where T : class, IEntity { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (actionType == DatabaseActionType.Insert || actionType == DatabaseActionType.Update) { SetIntoCache(data); } else if (actionType == DatabaseActionType.Delete) { RemoveFromCache(data); } DataQueue.Enqueue(new DatabaseAction(data, actionType)); }
public override void ResolveDataInQueue() { #region //获取枚举的匹配集合 if (string.IsNullOrWhiteSpace(SourceHtml)) { return; } Regex regex = new Regex(@"<(?<HxTag>h\d+)\s+[^>]*id=""枚举[^>]+>((?<Nested><\k<HxTag>[^>]*>)|</\k<HxTag>>(?<-Nested>)|.*?)*</\k<HxTag>>(?<clumns>((?!</table>).|\n)*)", RegexOptions.IgnoreCase | RegexOptions.Compiled); var enumsMatchs = regex.Matches(SourceHtml); #endregion #region //将每个HTML的内容描述转换为EnumDesc对象 //循环处理 foreach (Match m in enumsMatchs) { //定义数据表描述对象处理上下文 EnumDescContext context = new EnumDescContext(m.Value); //将HTMl信息解释为枚举EnumDesc的解释器 List <EnumExpression> exps = new List <EnumExpression>(); exps.Add(new EnumDescExpression()); //枚举描述信息解释器 exps.Add(new EnumOptionsExpression()); //枚举成员解释器 //循环执行文法解释器 foreach (var exp in exps) { exp.Interpret(context); } //将解释出来的EnumDesc加入数据队列 DataQueue.Enqueue(context.EnumDesc); } #endregion }
private void RecvRequestFromClient() { int availableBytes = 0; while (IsConnected) { if (tcpClient == null || tcpClient.Client == null || tcpClient.Connected == false) { if (OnSocketError != null) { OnSocketError(ID, new SocketEventArgs((int)SocketError.Shutdown, "")); } return; } try { availableBytes = tcpClient.Available; } catch (Exception ex) { if (OnSocketError != null) { OnSocketError(ID, new SocketEventArgs((int)SocketError.Disconnecting, "")); } return; } if (availableBytes > 0) { this.OnlineDate = DateTime.Now; byte[] byteArrayIn = new byte[availableBytes]; try { SocketError errCode; int bytesRead = 0; int recvLen = availableBytes; bytesRead = tcpClient.Client.Receive(byteArrayIn, 0, recvLen, SocketFlags.None, out errCode); if (bytesRead > 0) { byte[] data = new byte[bytesRead]; Array.Copy(byteArrayIn, data, bytesRead); DataQueue.Enqueue(data); } else { if (OnSocketError != null) { OnSocketError(ID, new SocketEventArgs((int)errCode, "")); } //logger.Error("connection broken error:" + errCode); } //if (RecvDataHandler != null) //RecvDataHandler(byteArrayIn, bytesRead); } catch (SocketException ex) { if (OnSocketError != null) { OnSocketError(ID, new SocketEventArgs((int)ex.ErrorCode, ex.Message)); } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } } Thread.Sleep(ThreadSleepInterval); } }
protected void PushToView(object model) { queueView.Enqueue(model); }