/// <summary> /// Insert terminal message into queue if it doesn't exist in queue and so on. /// </summary> /// <param name="terminalMessage"></param> public void InsertOrUpdate(TerminalMessage terminalMessage) { // Find command in existing queue. var instance = FindCommandInQueue(terminalMessage.CommandSequence, terminalMessage.CommandIndex); // Command doesn't exist in queue. if (instance == null) { // Insert command in queue. CommandsQueue.Add(terminalMessage); return; } // Update the command. instance.CommandSequence = terminalMessage.CommandSequence; instance.CommandIndex = terminalMessage.CommandIndex; instance.Command = terminalMessage.Command; instance.Status = terminalMessage.Status; instance.From = terminalMessage.From; instance.To = terminalMessage.To; instance.PalletNo = terminalMessage.PalletNo; instance.Filter = terminalMessage.Filter; instance.Date = terminalMessage.Date; instance.Sent = terminalMessage.Sent; instance.IsAck = terminalMessage.IsAck; instance.SentCount = terminalMessage.SentCount; }
public void OnRecv(CPacket msg) { Command command = new Command(msg); Debug.Log("OnRecv protocol: " + command.protocol + " turntoProcess: " + command.turnToProcess + " nowturn: " + CommandsManager.instance.nowTurn); text = "OnRecv protocol: " + command.protocol + " turntoProcess: " + command.turnToProcess + " nowturn: " + CommandsManager.instance.nowTurn; if (command.turnToProcess.Equals(nowTurn))//지금 턴에 실행해야하는 경우 { command.Process(); } else//다음턴에 혹은 그 이후 실행해야하는 경우 { commandsReceved.Add(command); } }
protected virtual bool OnRequest(HttpListenerContext context) { if (context.Request.HttpMethod == "OPTIONS") { ApisHandler.RespondOptions(context); return(true); } context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); var user = ApiHandler.CheckAuth(context, out bool logged); if (user != null || logged) { var serviceArgs = RequestArgs.NewRequestArgs(context, this, user); if (serviceArgs.Service == null) { serviceArgs.SendCode(HttpStatusCode.OK); } else if (serviceArgs.Service.CanbeDelayed(serviceArgs)) { CommandsQueue.Add(new CommandsParam(serviceArgs, ExecuteCommand, this)); return(false); } else { using (serviceArgs) { Api(serviceArgs); return(!serviceArgs.IsBusy); } } } else { context.Response.StatusCode = (int)HttpStatusCode.Forbidden; } return(true); }
/// <summary> /// Insert terminal message into queue. /// </summary> /// <param name="terminalMessage"></param> public void Insert(TerminalMessage terminalMessage) { CommandsQueue.Add(terminalMessage); }