public void SendRequest(OperationCode opCode, SubCode subCode, Dictionary <byte, object> parameters) { Debug.Log("到PhotonEngine的82行: " + opCode); parameters.Add((byte)ParameterCode.SubCode, subCode); peer.OpCustom((byte)opCode, parameters, true); Debug.Log("到PhotonEngine的85行: " + opCode); }
//客户端请求 服务端的回复 public void OnOperationResponse(OperationResponse operationResponse) { OperationCode opCode = (OperationCode)operationResponse.OperationCode; Request request = DictTool.GetValue <OperationCode, Request>(m_requestDic, opCode); request.OnOperationResponse(operationResponse); }
/// <summary> /// 将数据打包为 Modbus 和 Rtu 或者Tcp报文格式 /// </summary> /// <param name="modbusType">协议类型</param> /// <param name="operationCode">操作码字节</param> /// <param name="station">单元字节</param> /// <param name="data">数据</param> /// <returns></returns> public static byte[] DataPacking(ModbusType modbusType, OperationCode operationCode, byte station, params byte[] data) { List <byte> list = new List <byte>(); byte[] result = null; if (modbusType == ModbusType.Tcp) { list.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 }); byte[] length = BitConverter.GetBytes((short)(1 + 1 + data.Count())); list.Add(length[1]); list.Add(length[0]); list.Add(station); list.Add((byte)operationCode); list.AddRange(data); result = list.ToArray(); } if (modbusType == ModbusType.RTU) { list.Add(station); list.Add((byte)operationCode); list.AddRange(data); byte[] crc = GetModbusCRC16_Byte(list.ToArray()); list.AddRange(crc); result = list.ToArray(); } string s = BytesToHexString(result); return(result); }
public CategoryDeleted(OperationCode operationCode, Guid correlationId, Guid menuId, Guid categoryId) { OperationCode = (int)operationCode; CorrelationId = correlationId; MenuId = menuId; CategoryId = categoryId; }
public override void Put(T item) { var code = Find(item); if (code != OperationCode.NotFound) { _lastPutStatus = OperationCode.Error; return; } if (_slot == null) { _lastPutStatus = OperationCode.SlotNotCalculate; return; } if (CanPlaceItem() != OperationCode.CanBePlaced) { _lastPutStatus = OperationCode.CanNotBePlaced; return; } _values[(int)_slot] = item; _count++; }
protected override void ApplyCommand(Session session, QueryJson query) { string userName, password; userName = GetVariable(query.Message, "UserName"); password = GetVariable(query.Message, "Password"); string userPriv = DataBaseOperations.CheckUserLoginData(userName, password); OperationCode code = OperationCode.UserAuthorized; if (userPriv == "Admin") { session.UserRights = Rights.Admin; code = OperationCode.AdminAuthorized; } else if (userPriv == "User") { session.UserRights = Rights.User; code = OperationCode.UserAuthorized; } else { session.Dialog.SendMessage( new Msg(OperationCode.AnswerError, WRONG_LOGIN_OR_PASS)); } session.CreateLog(userName); session.WriteLog(userName + " connected!"); session.Dialog.SendMessage( new Msg(code, "Connected")); }
private void ReceiveAsyncCallback(IAsyncResult ar) { try { int count = clientSocket.EndReceive(ar); if (count == 0) { Close(); } msg.UpdateEndIndex(count); while (msg.Check()) { //Console.WriteLine("{0}, {1}, {2}", msg.ReadString(), msg.ReadInt(), msg.ReadBool()); OperationCode requestCode = (OperationCode)msg.ReadInt(); ActionCode actionCode = (ActionCode)msg.ReadInt(); //string data = msg.ReadString(); BaseController bc = ControllerManager.Instance.GetController(requestCode); if (bc == null) { throw (new Exception("controller not found RequestCode is " + requestCode)); } bc.HandleMessage(actionCode, msg, this, server); } if (clientSocket != null) { Start(); } } catch (Exception e) { Console.WriteLine("client {0}:{1} is disconnected!\n{2}", ip, port, e); Close(); } }
public void RegisterController(OperationCode opCode, ControllerBase controll) { if (!controllers.ContainsKey((byte)opCode)) { controllers.Add((byte)opCode, controll); } }
//当客户端向服务器发起请求,服务器给客户端发出响应,然后这个方法就会被调用 public void OnOperationResponse(OperationResponse operationResponse) { OperationCode opCode = (OperationCode)operationResponse.OperationCode; Request request = null; bool isGetRq = requestSet.TryGetValue(opCode, out request); if (isGetRq) { request.OnOperationResponse(operationResponse); } else { Debug.Log("there is no matching value about opCode."); } #region 测试 //根据不同的操作类型响应不同的事件 /*switch(operationResponse.OperationCode) * { * case 1: * Debug.Log("Receive a response form server."); * * //获取从服务端发送过来的数据 * Dictionary<byte, object> data = operationResponse.Parameters; * object valueServer; * data.TryGetValue(1, out valueServer); * Debug.Log(valueServer.ToString()); * break; * default: * break; * }*/ #endregion }
/// <summary> /// If the given operation code is a short branch, return the corresponding long branch. Otherwise return the given operation code. /// </summary> /// <param name="operationCode">An operation code.</param> public static OperationCode LongVersionOf(OperationCode operationCode) { switch (operationCode) { case OperationCode.Beq_S: return(OperationCode.Beq); case OperationCode.Bge_S: return(OperationCode.Bge); case OperationCode.Bge_Un_S: return(OperationCode.Bge_Un); case OperationCode.Bgt_S: return(OperationCode.Bgt); case OperationCode.Bgt_Un_S: return(OperationCode.Bgt_Un); case OperationCode.Ble_S: return(OperationCode.Ble); case OperationCode.Ble_Un_S: return(OperationCode.Ble_Un); case OperationCode.Blt_S: return(OperationCode.Blt); case OperationCode.Blt_Un_S: return(OperationCode.Blt_Un); case OperationCode.Bne_Un_S: return(OperationCode.Bne_Un); case OperationCode.Br_S: return(OperationCode.Br); case OperationCode.Brfalse_S: return(OperationCode.Brfalse); case OperationCode.Brtrue_S: return(OperationCode.Brtrue); case OperationCode.Leave_S: return(OperationCode.Leave); default: return(operationCode); } }
public static void RemoveListener(OperationCode type, Act act) { if (messageTable.ContainsKey(type)) { Delegate d = messageTable[type]; if (d == null) { MyGameServer.MyGameServer.log.Info(string.Format("Attempting to remove listener with for event type \"{0}\" but current listener is null.", type)); } else if (d.GetType() != act.GetType()) { MyGameServer.MyGameServer.log.Info(string.Format("Attempting to remove listener with inconsistent signature for event type {0}. Current listeners have type {1} and listener being removed has type {2}", type, d.GetType().Name, act.GetType().Name)); } else { messageTable[type] = (Act)messageTable[type] - act; if (d == null) { messageTable.Remove(type); } } } else { MyGameServer.MyGameServer.log.Info(string.Format("Attempting to remove listener for type \"{0}\" but Messenger doesn't know about this event type.", type)); } }
public IndexViewModel() { ConsentValidFromStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false); ConsentValidFromEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false); ConsentValidToStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false); ConsentValidToEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false); NotificationReceivedStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false); NotificationReceivedEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false); NotificationTypes = new SelectList(EnumHelper.GetValues(typeof(NotificationType)), dataTextField: "Value", dataValueField: "Key"); TradeDirections = new SelectList(EnumHelper.GetValues(typeof(TradeDirection)), dataTextField: "Value", dataValueField: "Key"); InterimStatus = new SelectList(new[] { new SelectListItem { Text = "Interim", Value = "true" }, new SelectListItem { Text = "Non-interim", Value = "false" } }, dataTextField: "Text", dataValueField: "Value"); OperationCodes = new MultiSelectList(EnumHelper.GetValues(typeof(OperationCode)), dataTextField: "Value", dataValueField: "Key"); NotificationStatuses = new SelectList(GetCombinedNotificationStatuses(), dataTextField: "Name", dataValueField: "StatusId", dataGroupField: "TradeDirection", selectedValue: null); SelectedOperationCodes = new OperationCode[] { }; }
public override void OnResponse(OperationResponse response) { base.OnResponse(response); OperationCode opCode = (OperationCode)response.OperationCode; ErrorCode errCode = (ErrorCode)response.ReturnCode; Dictionary <byte, object> parameter = response.Parameters; if (errCode != ErrorCode.Success) { this.HandleErrorCode(errCode); Debug.Log(string.Format("ResponseReceived, OperationCode = {0}, ReturnCode = {1}, DebugMsg = {2}", opCode, errCode, response.DebugMessage)); return; } switch (opCode) { case OperationCode.UserUpdate: { SubCode subCode = (SubCode)parameter[(byte)ParameterCode.SubCode]; switch (subCode) { case SubCode.AddFriend: HandleReponseAddFriend(response); break; } } break; default: break; } }
internal Operation(OperationCode operationCode, uint offset, ILocation location, object /*?*/ value) { this.operationCode = operationCode; this.offset = offset; this.location = location; this.value = value; }
private IEnumerable <PMConfig> GetProperties(NativeActivityContext context) { var artL = ArtLst.Get(context); var entity = Entity.Get(context); var obj = entity as WMSBusinessObject; if (obj == null) { throw new NotImplementedException(string.Format("Тип '{0}' не поддерживается", entity.GetType())); } var objname = SourceNameHelper.Instance.GetSourceName(obj.GetType()); var operationCode = OperationCode.Get(context); var resLst = new List <PMConfig>(); using (var pmConfigMgr = IoC.Instance.Resolve <IPMConfigManager>()) { SetUnitOfWork(context, pmConfigMgr); // параметры для сверки по артикулу и операции, фильтр по имени сущности foreach (var art in artL) { resLst.AddRange(pmConfigMgr.GetPMConfigByParamListByArtCode(art.ArtCode, operationCode, null).Where(pm => pm.ObjectEntitycode_R == objname.ToUpper())); } } return(resLst); }
public static void RemoveListener(OperationCode type, Act act) { if (msgTable.ContainsKey(type)) { Delegate dgt = msgTable[type]; if (dgt == null) { Log.ErrorFormat( "Event Type {0}에 대한 Listener 제거를 시도했지만 현재 Listener가 null입니다.", type); } else if (dgt.GetType( ) != act.GetType( )) { Log.ErrorFormat( "Event Type {0}에 대한 서명이 일치하지 않는 Listener를 제거하려고 합니다." + "현재 Listener에는 {1} Type가 있으며 제가하려는 Listener에는 {2} Type이 있습니다.", type, dgt.GetType( ).Name, act.GetType( ).Name); } else { msgTable[type] = (Act)msgTable[type] - act; if (dgt == null) { msgTable.Remove(type); } } } else { Log.ErrorFormat("{0} Type에 대한 Listener를 제거하려고 시도했지만 Messenger에 해당 Event Type이 없습니다.", type); } }
/// <summary> /// Отпраляет лишь код. /// </summary> /// <param name="code">Код</param> public void SendMessage(OperationCode code) { Msg msg = new Msg(code, ""); byte[] buf = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(msg)); Handler.Send(buf, buf.Length, SocketFlags.None); }
public override void OnResponse(OperationResponse response) { base.OnResponse(response); OperationCode opCode = (OperationCode)response.OperationCode; ErrorCode errCode = (ErrorCode)response.ReturnCode; if (errCode != ErrorCode.Success) { Debug.Log(string.Format("ResponseReceived, OperationCode = {0}, ReturnCode = {1}, DebugMsg = {2}", opCode, errCode, response.DebugMessage)); this.HandleErrorCode(errCode); return; } if (errCode == ErrorCode.Success) { switch (opCode) { case OperationCode.ZonesList: Debug.Log("ZonesList"); OnZonesList(response); break; } } else { switch (opCode) { case OperationCode.SignIn: MessageBox.ShowDialog(errCode.ToString(), UINoticeManager.NoticeType.Message); break; } } }
private void OnOperationClick(object sender, EventArgs e) { OnCalculationClick(sender, e); lastResult = ConvertToDecimal(lblDisplay.Text); isZero = true; isDotEntered = false; switch ((sender as Button).Text[0]) { case '+': operation = OperationCode.ADD; break; case '-': if (isZero) { SetToDisplay("-"); isZero = false; break; } else { operation = OperationCode.SUBTRACT; break; } case '*': operation = OperationCode.MULTIPLY; break; case '/': operation = OperationCode.DIVIDE; break; } }
void ParseBuildInFunction(OperationCode opcode, int param_count) { GetToken(); if (m_token_type != TokenType.LEFT_PAREN) { LogWrapper.LogError("Expression: ParseBuildInFunction, '(' expected"); } if (param_count > 0) { GetToken(); ParseExpression(); --param_count; while (param_count > 0) { if (m_token_type != TokenType.COMMA) { m_error_occurred = true; LogWrapper.LogError("Expression: ParseBuildInFunction, ',' expected"); return; } GetToken(); ParseExpression(); --param_count; } } if (m_token_type != TokenType.RIGHT_PAREN) { m_error_occurred = true; LogWrapper.LogError("Expression: ParseBuildInFunction, ')' expected"); return; } AppendOperation(opcode); GetToken(); }
internal Ledger(ContractService contractService, WalletContract contract, OperationCode operation, BitcoinPubKeyAddress utxoReceiver, BitcoinPubKeyAddress tokenReceiver = null, decimal?amount = null, string referenceCode = null) { _contract = contract; Operation = operation; TokenReceiver = tokenReceiver; TokenReceiverHash = tokenReceiver.ExtractWitnessProgram(); ReferenceCode = referenceCode; UtxoReceiver = utxoReceiver; if (operation == OperationCode.Issue && tokenReceiver == null) { TokenReceiverHash = new BitcoinPubKeyAddress(contract.OwnerPublicAddress, contractService.MainNetwork).ExtractWitnessProgram(); } if (amount < 0) { throw new InvalidOperationException("The amount cannot be negative."); } if (amount.HasValue) { Amount = amount.Value; } else if (operation != OperationCode.Issue) { throw new ArgumentNullException("Amount cannot be null if the operation is not issuance of the owner address."); } else { Amount = contract.TotalSupply; } }
public void GetResponseStatus_Translate_Locked_Status(OperationCode operationCode, ResponseStatus status, ResponseStatus translatedStatus) { var operation = new FakeOperation(operationCode, status); var actual = operation.GetResponseStatus(); Assert.AreEqual(translatedStatus, actual); }
/// <summary> /// If the given operation code is a long branch, return the corresponding short branch. Otherwise return the given operation code. /// </summary> /// <param name="operationCode">An operation code.</param> public static OperationCode ShortVersionOf(OperationCode operationCode) { switch (operationCode) { case OperationCode.Beq: return(OperationCode.Beq_S); case OperationCode.Bge: return(OperationCode.Bge_S); case OperationCode.Bge_Un: return(OperationCode.Bge_Un_S); case OperationCode.Bgt: return(OperationCode.Bgt_S); case OperationCode.Bgt_Un: return(OperationCode.Bgt_Un_S); case OperationCode.Ble: return(OperationCode.Ble_S); case OperationCode.Ble_Un: return(OperationCode.Ble_Un_S); case OperationCode.Blt: return(OperationCode.Blt_S); case OperationCode.Blt_Un: return(OperationCode.Blt_Un_S); case OperationCode.Bne_Un: return(OperationCode.Bne_Un_S); case OperationCode.Br: return(OperationCode.Br_S); case OperationCode.Brfalse: return(OperationCode.Brfalse_S); case OperationCode.Brtrue: return(OperationCode.Brtrue_S); case OperationCode.Leave: return(OperationCode.Leave_S); default: return(operationCode); } }
public override void OnResponse(OperationResponse response) { base.OnResponse(response); OperationCode opCode = (OperationCode)response.OperationCode; ErrorCode errCode = (ErrorCode)response.ReturnCode; if (errCode != ErrorCode.Success) { this.HandleErrorCode(errCode); Debug.Log(string.Format("ResponseReceived, OperationCode = {0}, ReturnCode = {1}, DebugMsg = {2}", opCode, errCode, response.DebugMessage)); return; } switch (opCode) { case OperationCode.UserUpdate: { SubCode subCode = (SubCode)response.Parameters[(byte)ParameterCode.SubCode]; switch (subCode) { case SubCode.GetHires: { HandleGetHires(response); } break; } } break; default: break; } }
public void PutAndRemoveOperationsOfNotInitializedDictionaryReturnsOperationCodeNotInitialized() { NativeDictionaryModel <int> dict = null; OperationCode putStatus = OperationCode.Ok, removeStatus = OperationCode.Ok; "Given not initialized dictionary" .x((() => { dict = new NativeDictionaryModel <int>(); })); "When user tries to put new item and remove" .x(() => { dict.Put("Item", 2); putStatus = dict.LastPutStatus(); dict.Remove("Item"); removeStatus = dict.LastRemoveStatus(); }); "Then last put and remove statuses should be 'Not initialized'" .x(() => { putStatus.Should().Be(OperationCode.NotInitialized); removeStatus.Should().Be(OperationCode.NotInitialized); }); }
private void Write(ref TransactionToken token, OperationCode operation, TKey key, TValue value) { AssertionFailedException.Assert(token.State == StateOpen); MemoryStream buffer = token.Object as MemoryStream; if (buffer == null) { token.Object = buffer = new MemoryStream(); PrimitiveSerializer.Int32.WriteTo(0, buffer); PrimitiveSerializer.Int32.WriteTo(unchecked ((int)token.Handle), buffer); PrimitiveSerializer.Int16.WriteTo(0, buffer); } PrimitiveSerializer.Int16.WriteTo((short)operation, buffer); _options.KeySerializer.WriteTo(key, buffer); if (operation != OperationCode.Remove) { _options.ValueSerializer.WriteTo(value, buffer); } //Increment the operation counter at offset 8 long pos = buffer.Position; buffer.Position = 8; short count = PrimitiveSerializer.Int16.ReadFrom(buffer); buffer.Position = 8; PrimitiveSerializer.Int16.WriteTo(++count, buffer); buffer.Position = pos; }
public bool UniversalSwitch(int switchId, Channel.State switchState) { if (switchId == 0) { throw new InvalidOperationException("SwitchId not set"); } if (switchId < 1 || switchId > 255) { throw new InvalidOperationException($"Invalid SwitchId {switchId}"); } var additionalContent = new byte[2]; additionalContent[0] = (byte)switchId; additionalContent[1] = (byte)switchState; OperationCode = OperationCode.UniversalSwitchControl; var data = new Command { AdditionalContent = additionalContent, OperationCode = OperationCode.UniversalSwitchControl, SourceAddress = Controller.SourceAddress, SourceDeviceType = Controller.SourceDeviceType, TargetAddress = DeviceAddress }; var result = Controller.WriteBus(data); return(result); }
/// <summary> /// Encodes the specified value. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="value">The value of the key to encode.</param> /// <param name="flags">The flags used for decoding the response.</param> /// <param name="opcode"></param> /// <returns></returns> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.ArgumentOutOfRangeException"></exception> public byte[] Encode <T>(T value, Flags flags, OperationCode opcode) { byte[] bytes; switch (flags.DataFormat) { case DataFormat.Reserved: case DataFormat.Private: case DataFormat.String: bytes = Encode(value, flags.TypeCode, opcode); break; case DataFormat.Json: bytes = SerializeAsJson(value); break; case DataFormat.Binary: if (typeof(T) == typeof(byte[])) { bytes = value as byte[]; } else { var msg = string.Format("The value of T does not match the DataFormat provided: {0}", flags.DataFormat); throw new ArgumentException(msg); } break; default: throw new ArgumentOutOfRangeException(); } return(bytes); }
public override void OnResponse(OperationResponse response) { _waitServer = false; base.OnResponse(response); OperationCode opCode = (OperationCode)response.OperationCode; ErrorCode errCode = (ErrorCode)response.ReturnCode; if (errCode != ErrorCode.Success) { Debug.Log("errCode" + errCode + " - opCode " + opCode); this.HandleErrorCode(errCode); return; } switch (opCode) { case OperationCode.UserUpdate: if (errCode == ErrorCode.Success) { HandleUserUpdate(response); } break; default: break; } }
/// <summary> /// Encodes the specified value. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="value">The value.</param> /// <param name="typeCode">Type to use for encoding</param> /// <param name="opcode"></param> /// <returns></returns> /// <exception cref="System.ArgumentOutOfRangeException"></exception> public byte[] Encode <T>(T value, TypeCode typeCode, OperationCode opcode) { var bytes = new byte[] { }; switch (typeCode) { case TypeCode.Empty: case TypeCode.DBNull: case TypeCode.String: case TypeCode.Char: Converter.FromString(Convert.ToString(value), ref bytes, 0); break; case TypeCode.Int16: Converter.FromInt16(Convert.ToInt16(value), ref bytes, 0, false); break; case TypeCode.UInt16: Converter.FromUInt16(Convert.ToUInt16(value), ref bytes, 0, false); break; case TypeCode.Int32: Converter.FromInt32(Convert.ToInt32(value), ref bytes, 0, false); break; case TypeCode.UInt32: Converter.FromUInt32(Convert.ToUInt32(value), ref bytes, 0, false); break; case TypeCode.Int64: Converter.FromInt64(Convert.ToInt64(value), ref bytes, 0, false); break; case TypeCode.UInt64: if (opcode == OperationCode.Increment || opcode == OperationCode.Decrement) { Converter.FromUInt64(Convert.ToUInt64(value), ref bytes, 0, true); } else { Converter.FromUInt64(Convert.ToUInt64(value), ref bytes, 0, false); } break; case TypeCode.Single: case TypeCode.Double: case TypeCode.Decimal: case TypeCode.DateTime: case TypeCode.Boolean: case TypeCode.SByte: case TypeCode.Byte: case TypeCode.Object: bytes = SerializeAsJson(value); break; default: throw new ArgumentOutOfRangeException(); } return(bytes); }
public void RegisterController(OperationCode opCode,ControllerBase controll) { if (!controllers.ContainsKey((byte)opCode)) { controllers.Add((byte)opCode, controll); } }
private static void AssertOperation(IActivityInstance activityInstance, OperationCode operationCode) { if (activityInstance.ActivityTemplate.AllowedActions.All(p => p.OperationCode != operationCode)) { throw new InvalidOperationException("当前节点不允许此操作"); } }
//用于注册Controller的方法 public void RegisterController(OperationCode opCode, ControllerBase controller) { controllers.Add((byte) opCode, controller); //if (!controllers.ContainsKey((byte) opCode)) //{ // controllers.Add((byte) opCode, controller); //} }
public void Operation_Code_Is_Correctly_Deserialized(byte[] flagBytes, OperationCode expectedValue) { var bytes = _headerBytes.WithFlagBytes(flagBytes).ToArray(); var message = _serializer.DeserializeFromBytes(bytes); Assert.That(message.OperationCode, Is.EqualTo(expectedValue)); }
public static ParameterDefinition[] ParametersInfo(OperationCode funcOpcode) { ParameterDefinition[] info; if(!_paramInfoCache.TryGetValue(funcOpcode, out info)) { info = _paramInfoGenerators[funcOpcode](); _paramInfoCache.Add(funcOpcode, info); } return info; }
public static OperationCode[] GetOperationCodes() { var values = Enum.GetValues(typeof(OperationCode)); var result = new OperationCode[values.Length - BUILTIN_OPCODES_INDEX]; for (int i = BUILTIN_OPCODES_INDEX, j = 0; i < values.Length; i++, j++) { result[j] = (OperationCode)values.GetValue(i); } return result; }
public static string GetName(OperationCode OperationEnum) { switch (OperationEnum) { case OperationCode.BootRequest: return "BootRequest"; case OperationCode.BootReply: return "BootReply"; default: return "Unknown"; } }
public OperationResponse operationRequest( DataPhaseInfo dpi, OperationCode code, UInt32 tid, UInt32 param1 = 0, UInt32 param2 = 0, UInt32 param3 = 0, UInt32 param4 = 0, UInt32 param5 = 0) { OperationRequest request = new OperationRequest( dpi, code, tid, param1, param2, param3, param4, param5); request.send(cmdStream); OperationResponse response = new OperationResponse(); response.recv(cmdStream); return response; }
public OperationRequest(DataPhaseInfo dpi, OperationCode ope, UInt32 tid, UInt32 param1 = 0, UInt32 param2 = 0, UInt32 param3 = 0, UInt32 param4 = 0, UInt32 param5 = 0) { DataPhaseInfo = dpi; OperationCode = ope; TransactionID = tid; Parameter1 = param1; Parameter2 = param2; Parameter3 = param3; Parameter4 = param4; Parameter5 = param5; PacketType = PacketType.OperationRequest; }
//用来转发请求 public static void TransmitRequest(ClientPeer peer, OperationRequest request,OperationCode opCode) { foreach (ClientPeer temp in peer.Team.clientPeers) { if (temp != peer) { EventData data = new EventData(); data.Parameters = request.Parameters; ParameterTool.AddOperationcodeSubcodeRoleID(data.Parameters, opCode, peer.LoginRole.ID); temp.SendEvent(data, new SendParameters()); } } }
public static NotificationType GetCodeType(OperationCode operationCode) { var attribute = typeof(OperationCode).GetField(operationCode.ToString()) .GetCustomAttribute<OperationCodeTypeAttribute>(false); if (attribute == null) { throw new InvalidOperationException("Operation Code " + operationCode + " does not provide a Operation Code type attribute."); } return attribute.OperationType; }
public void ProcessOperationRequest(OperationCode code, IDictionary<byte, object> parameters) { if (code == OperationCode.HandleOperation) { _service.HandleOperation(_reader.ReadOperation(parameters)); } else if (code == OperationCode.HandleOperationWithResponse) { _service.HandleOperationWithResponse(_reader.ReadOperation(parameters), _reader.ReadPromiseId(parameters)); } else if (code == OperationCode.HandleResponse) { _service.HandleResponse(_reader.ReadResponse(parameters)); } }
public async Task<int> LogOperationAsync(int cardId, decimal amount, OperationCode code, DateTime date) { var operation = new Operation { CardId = cardId, Amount = amount, Code = code, Date = date }; _context.Operations.Add(operation); await _context.SaveChangesAsync(); return operation.Id; }
public ResponseCode operationRequest( DataPhaseInfo dpi, OperationCode code, UInt32 tid, UInt32 param1 = 0, UInt32 param2 = 0, UInt32 param3 = 0, UInt32 param4 = 0, UInt32 param5 = 0) { // OperationRequestを送信 byte[] data = operationRequestData(dpi, code, tid, param1, param2, param3, param4, param5); stream.Write(data, 0, data.Length); // データフェーズがあれば送信(未実装) if (dpi == DataPhaseInfo.DataOutPhase) { sendDataPhase(tid); } // データを受信 data = recvAllData(); UInt32 length = BitConverter.ToUInt32(data, 0); PacketType pt = (PacketType)BitConverter.ToUInt32(data, 4); // データフェーズがあれば受信する if (pt == PacketType.StartData) { // 全データサイズ UInt64 tlen = BitConverter.ToUInt64(data, 12); recvData = new byte[tlen]; int recvDataCount = 0; do { data = recvAllData(); length = BitConverter.ToUInt32(data, 0); pt = (PacketType)BitConverter.ToUInt32(data, 4); Array.Copy(data, 12, recvData, recvDataCount, length - 12); recvDataCount += (int)length - 12; } while (pt != PacketType.EndData); data = recvAllData(); length = BitConverter.ToUInt32(data, 0); pt = (PacketType)BitConverter.ToUInt32(data, 4); } return (ResponseCode)BitConverter.ToUInt16(data, 8); }
private static uint SizeOfOperationCode(OperationCode opcode) { if (((int)opcode) > 0xff && (opcode < OperationCode.Array_Create)) return 2; return 1; }
/// <summary> /// The check default event params. /// </summary> /// <param name="eventArgs"> /// The event args. /// </param> /// <param name="operationCode"> /// The operation code. /// </param> /// <param name="actorNumber"> /// The actor number. /// </param> protected static void CheckDefaultEventParameters(EventData eventArgs, OperationCode operationCode, int actorNumber) { CheckEventParam(eventArgs, ParameterKey.ActorNr, actorNumber); }
/// <summary> /// The check default operation params. /// </summary> /// <param name="response"> /// The response. /// </param> /// <param name="operationCode"> /// The operation code. /// </param> protected static void CheckDefaultOperationParameters(OperationResponse response, OperationCode operationCode) { Assert.AreEqual(operationCode, response.OperationCode, "Unexpected operation code received."); Assert.AreEqual(0, response.ReturnCode, string.Format("Response has Error. ERR={0}, DBG={1}", response.ReturnCode, response.DebugMessage)); }
private Expression ParseBinaryOperation(OperationCode currentOpcode) { switch (currentOpcode) { default: Debug.Assert(false); goto case OperationCode.Xor; case OperationCode.Add: case OperationCode.Add_Ovf: case OperationCode.Add_Ovf_Un: return this.ParseAddition(currentOpcode); case OperationCode.And: return this.ParseBinaryOperation(new BitwiseAnd()); case OperationCode.Ceq: return this.ParseBinaryOperation(new Equality()); case OperationCode.Cgt: return this.ParseBinaryOperation(new GreaterThan()); case OperationCode.Cgt_Un: return this.ParseBinaryOperation(new GreaterThan() { IsUnsignedOrUnordered = true }); case OperationCode.Clt: return this.ParseBinaryOperation(new LessThan()); case OperationCode.Clt_Un: return this.ParseBinaryOperation(new LessThan() { IsUnsignedOrUnordered = true }); case OperationCode.Div: return this.ParseBinaryOperation(new Division()); case OperationCode.Div_Un: return this.ParseUnsignedBinaryOperation(new Division() { TreatOperandsAsUnsignedIntegers = true }); case OperationCode.Mul: case OperationCode.Mul_Ovf: case OperationCode.Mul_Ovf_Un: return this.ParseMultiplication(currentOpcode); case OperationCode.Or: return this.ParseBinaryOperation(new BitwiseOr()); case OperationCode.Rem: return this.ParseBinaryOperation(new Modulus()); case OperationCode.Rem_Un: return this.ParseUnsignedBinaryOperation(new Modulus() { TreatOperandsAsUnsignedIntegers = true }); case OperationCode.Shl: return this.ParseBinaryOperation(new LeftShift()); case OperationCode.Shr: return this.ParseBinaryOperation(new RightShift()); case OperationCode.Shr_Un: RightShift shrun = new RightShift(); shrun.RightOperand = this.PopOperandStack(); shrun.LeftOperand = this.PopOperandStackAsUnsigned(); return shrun; case OperationCode.Sub: case OperationCode.Sub_Ovf: case OperationCode.Sub_Ovf_Un: return this.ParseSubtraction(currentOpcode); case OperationCode.Xor: return this.ParseBinaryOperation(new ExclusiveOr()); } }
/// <summary> /// MessageID main constructor. /// </summary> /// <param name="serviceIdentifier">The Service Identifier (MIH Services).</param> /// <param name="operationCode">The Operation Code.</param> /// <param name="AID">The Action Identifier.</param> public MessageID(ServiceIdentifier serviceIdentifier, OperationCode operationCode, ushort AID) { this.SID = serviceIdentifier; this.OpCode = operationCode; this.AIDValue = AID; }
private Expression ParseSubtraction(OperationCode currentOpcode) { Subtraction subtraction = new Subtraction(); subtraction.CheckOverflow = currentOpcode != OperationCode.Sub; if (currentOpcode == OperationCode.Sub_Ovf_Un) { subtraction.TreatOperandsAsUnsignedIntegers = true; return this.ParseUnsignedBinaryOperation(subtraction); } else return this.ParseBinaryOperation(subtraction); }
private Expression ParseAddition(OperationCode currentOpcode) { Addition addition = new Addition(); addition.CheckOverflow = currentOpcode != OperationCode.Add; if (currentOpcode == OperationCode.Add_Ovf_Un) { addition.TreatOperandsAsUnsignedIntegers = true; //force use of unsigned addition, even for cases where the operands are expressions that result in signed values return this.ParseUnsignedBinaryOperation(addition); } else return this.ParseBinaryOperation(addition); }
private ITypeReference TypeFor(OperationCode operationCode) { switch (operationCode) { case OperationCode.Stelem_I: return this.host.PlatformType.SystemIntPtr; case OperationCode.Stelem_I1: return this.host.PlatformType.SystemInt8; case OperationCode.Stelem_I2: return this.host.PlatformType.SystemInt16; case OperationCode.Stelem_I4: return this.host.PlatformType.SystemInt32; case OperationCode.Stelem_I8: return this.host.PlatformType.SystemInt64; case OperationCode.Stelem_R4: return this.host.PlatformType.SystemFloat32; case OperationCode.Stelem_R8: return this.host.PlatformType.SystemFloat64; case OperationCode.Stelem_Ref: return this.host.PlatformType.SystemObject; } return Dummy.TypeReference; }
/// <summary> /// OperationRequestのデータを作成する /// </summary> /// <param name="dpi"></param> /// <param name="oc"></param> /// <param name="tid"></param> /// <param name="param1"></param> /// <param name="param2"></param> /// <param name="param3"></param> /// <param name="param4"></param> /// <param name="param5"></param> /// <returns></returns> private byte[] operationRequestData(DataPhaseInfo dpi, OperationCode oc, UInt32 tid, UInt32 param1 = 0, UInt32 param2 = 0, UInt32 param3 = 0, UInt32 param4 = 0, UInt32 param5 = 0) { UInt32 length = (UInt32)(4 + 4 + 4 + 2 + 4 + 4 + 4 + 4 + 4 + 4); byte[] data = new byte[length]; Array.Copy(BitConverter.GetBytes(length), data, 4); Array.Copy(BitConverter.GetBytes((UInt32)PacketType.OperationRequest), 0, data, 4, 4); Array.Copy(BitConverter.GetBytes((UInt32)dpi), 0, data, 8, 4); Array.Copy(BitConverter.GetBytes((UInt16)oc), 0, data, 12, 2); Array.Copy(BitConverter.GetBytes(tid), 0, data, 14, 4); Array.Copy(BitConverter.GetBytes(param1), 0, data, 18, 4); Array.Copy(BitConverter.GetBytes(param2), 0, data, 22, 4); Array.Copy(BitConverter.GetBytes(param3), 0, data, 26, 4); Array.Copy(BitConverter.GetBytes(param4), 0, data, 30, 4); Array.Copy(BitConverter.GetBytes(param5), 0, data, 34, 4); return data; }
public static ParameterDefinition[] ParametersInfo(OperationCode funcOpcode) { return _paramInfoCache[funcOpcode]; }
private static void AddFunc(OperationCode opCode, params ParameterDefinition[] parameters) { _paramInfoCache[opCode] = parameters; }
public void SendOperation(OperationCode code, Dictionary<byte, object> parameters) { SendEvent(new EventData((byte) code, parameters), new SendParameters {Unreliable = false}); }
public void Operation_Code_Maps_To_Correct_Byte_Value(OperationCode operationCode, byte expectedValue) { Assert.That((byte)operationCode, Is.EqualTo(expectedValue)); }
public WasteOperationCode(OperationCode operationCode) { OperationCode = operationCode; }
internal CilInstruction(OperationCode cilOpCode, MethodBodyDocument document, uint offset, object/*?*/ value) { this.CilOpCode = cilOpCode; this.document = document; this.offset = offset; this.Value = value; }
private Expression ParseMultiplication(OperationCode currentOpcode) { Multiplication multiplication = new Multiplication(); multiplication.CheckOverflow = currentOpcode != OperationCode.Mul; if (currentOpcode == OperationCode.Mul_Ovf_Un) { multiplication.TreatOperandsAsUnsignedIntegers = true; return this.ParseUnsignedBinaryOperation(multiplication); } else return this.ParseBinaryOperation(multiplication); }