コード例 #1
0
        public string CommandString()
        {
            var commandString = CmdId.ToString(CultureInfo.InvariantCulture);

            foreach (var argument in Arguments)
            {
                commandString += FieldSeparator + argument;
            }
            commandString += CommandSeparator;
            return(commandString);
        }
コード例 #2
0
ファイル: Broker.cs プロジェクト: soolafsen/EmpyrionAPITools
        public static void HandleGameEvent(CmdId eventId, ushort seqNr, object data)
        {
            var apiEvent = new apiEvent(eventId, seqNr, data);

            log(() => $"receiving event {eventId.ToString()}:{seqNr}");

            Delegate handler;

            if (eventTable.TryGetValue(eventId, out handler))
            {
                handler.DynamicInvoke(new object[] { data });
            }


            if (!commandTracker.ContainsKey(seqNr))
            {
                return;
            }

            var outstandingRequestList = commandTracker[seqNr];

            var firstApplicableRequest = outstandingRequestList.FirstOrDefault(x => x.call.ResponseCmdId == eventId || eventId == CmdId.Event_Error);

            if (firstApplicableRequest == null)
            {
                return;
            }

            outstandingRequestList.Remove(firstApplicableRequest);

            if (outstandingRequestList.Count > 0)
            {
                commandTracker[seqNr] = outstandingRequestList;
            }
            else
            {
                commandTracker.Remove(seqNr);
            }

            if (eventId == CmdId.Event_Error && firstApplicableRequest.errorHandler != null)
            {
                firstApplicableRequest.errorHandler((ErrorInfo)data);
                return;
            }

            firstApplicableRequest.responseHandler(eventId, data);
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: kevincwq/Balancer
        public string CommandString()
        {
            if (CommunicationManager == null)
            {
                throw new InvalidOperationException("CommunicationManager was not set for command.");
            }

            var commandString = new StringBuilder(CmdId.ToString(CultureInfo.InvariantCulture));

            foreach (var argument in Arguments)
            {
                commandString.Append(CommunicationManager.FieldSeparator).Append(argument);
            }
            commandString.Append(CommunicationManager.CommandSeparator);

            return(commandString.ToString());
        }