public static string GetQueueName <TMessage>() where TMessage : new() { var obj = new TMessage(); var imsg = obj as IQueueMessage; if (imsg != null) { return(imsg.QueueName); } else { return(obj.GetType().FullName); } }
public void WriteMessageBegin(TMessage message) { if (StrictWrite) { uint version = Version1 | (uint)(message.type); WriteI32((int)version); WriteString(message.name); WriteI32(message.seqID); } // else // { // WriteString(message.name); // WriteByte((sbyte)message.type); // WriteI32(message.seqID); // } }
public override async Task WriteMessageBeginAsync(TMessage message, CancellationToken cancellationToken) { switch (message.Type) { case TMessageType.Call: case TMessageType.Oneway: await base.WriteMessageBeginAsync(new TMessage($"{_serviceName}{Separator}{message.Name}", message.Type, message.SeqID), cancellationToken); break; default: await base.WriteMessageBeginAsync(message, cancellationToken); break; } }
public void recv_ShowInGameOverlay() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } ShowInGameOverlay_result result = new ShowInGameOverlay_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); return; }
public void recv_publishCommand() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } publishCommand_result result = new publishCommand_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); return; }
public void recv_testCase4() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } testCase4_result result = new testCase4_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); return; }
public void recv_cancelTask() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } cancelTask_result result = new cancelTask_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); return; }
public void recv_VideoCapture() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } VideoCapture_result result = new VideoCapture_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); return; }
internal override void RecordExtract(TMessage message) { if (verifyOnImport) { ((SymTTransfer)message.SVX_symT).payloadSecretsVerifiedOnImport.Add(new VerifyOnImportEntry { fieldPath = accessor.name, secretGeneratorTypeFullName = generator.GetType().FullName }); var secret = accessor.Get(message); SVX_Ops.TransferNested(secret.theParams, generator.Signer); } // If unverified, we leave the SymT inactive, which is weird. // XXX: We should TransferNested. We just need the current // principal here in order to generate a facet for the producer. }
public void recv_Speakwords() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } Speakwords_result result = new Speakwords_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); return; }
/// <summary> /// 处理返回消息 /// </summary> /// <param name="msgData">返回消息</param> private object DealRepMessage(byte[] msgData) { TSerializer serializerResp = new TBinarySerializer(); serializerResp.FromBytes(msgData); TMessage respMsg = serializerResp.ReadMessageBegin(); if (respMsg.Type == TMessageType.Exception) { this.RaiseDealMessageExceptionEvent(TApplicationException.Read(serializerResp)); serializerResp.ReadMessageEnd(); serializerResp.Flush(); return(null);; } if (respMsg.Type != TMessageType.RpcReply) { this.RaiseDealMessageExceptionEvent(new ApplicationException("非法的返回类型:" + respMsg.Type.ToString())); serializerResp.ReadMessageEnd(); serializerResp.Flush(); return(null); } string[] temp = respMsg.Name.Split('_'); DynMethodInstance dynMethodInstance = new DynMethodInstance(temp[0], temp[1]); try { dynMethodInstance.Result = DynSerialize.ReadResult(serializerResp, dynMethodInstance); } catch (Exception ex) { this.RaiseDealMessageExceptionEvent(ex); serializerResp.ReadMessageEnd(); serializerResp.Flush(); } // 消息结束 serializerResp.ReadMessageEnd(); serializerResp.Flush(); return(dynMethodInstance.Result); }
private async Task OnUnknownMessageReceived_Default(TMessage message) { ASSERT(message != null, $"Missing parameter '{nameof(message)}'"); if (string.IsNullOrWhiteSpace(message.TryGetString(MessageKeys.KeySenderID))) { FAIL($"{nameof(MessageHandler)}: Received message with unknown type '{message.TryGetString(MessageKeys.KeyMessageHandler)}'"); // Discard } else { // Send response var response = Broker.FillAsResponse(source: message, destination: Broker.NewMessage()); try{ throw new ArgumentException($"{nameof(MessageHandler)}: Received message with unknown type '{message.TryGetString(MessageKeys.KeyMessageHandler)}'"); } catch (System.Exception ex) { Broker.FillException(response, ex); }; await Broker.ReceiveMessages(new TMessage[] { response }); } }
/** * Prepends the service name to the function name, separated by TMultiplexedProtocol.SEPARATOR. * Args: * tMessage The original message. */ public override void WriteMessageBegin(TMessage tMessage) { switch (tMessage.Type) { case TMessageType.Call: case TMessageType.Oneway: base.WriteMessageBegin(new TMessage( ServiceName + SEPARATOR + tMessage.Name, tMessage.Type, tMessage.SeqID)); break; default: base.WriteMessageBegin(tMessage); break; } }
/// <param name="cookies">Contains the ASP.NET session cookie</param> private HttpClient(string handlerUrl, System.Net.CookieContainer cookies, IMessageReceiver messageReceiver = null, TMessage initMessageTemplate = null) : base(messageReceiver) { ASSERT(!string.IsNullOrWhiteSpace(handlerUrl), $"Missing parameter '{nameof(handlerUrl)}'"); ASSERT(cookies != null, $"Missing parameter '{nameof(cookies)}'"); HandlerUrl = handlerUrl; Cookies = cookies; InitMessage = CreateRootMessage_Init(); if (initMessageTemplate != null) { foreach (var pair in initMessageTemplate) { InitMessage[pair.Key] = pair.Value; } } }
public override async ValueTask <TMessage> ReadMessageBeginAsync(CancellationToken cancellationToken) { TMessage tMessage = await base.ReadMessageBeginAsync(cancellationToken); if (tMessage.Type == TMessageType.Exception) { TApplicationException x = await TApplicationException.ReadAsync(this, cancellationToken); //TraceUtils.submitAdditionalAnnotation(Constants.TRACE_THRIFT_EXCEPTION, StringUtil.trimNewlineSymbolAndRemoveExtraSpace(x.getMessage())); //TraceUtils.endAndSendLocalTracer(); } else if (tMessage.Type == TMessageType.Reply) { //TraceUtils.endAndSendLocalTracer(); } return(tMessage); }
private bool InOneWayRequest() { bool isOneWayMethod = false; // Create a temporary transport wrapping the output buffer, so that we can read the method name for this message using (TChannelBufferInputTransport requestReadTransport = new TChannelBufferInputTransport(_requestBufferTransport.OutputBuffer.Duplicate())) { using (TProtocol protocol = _channel.ProtocolFactory.GetOutputProtocolFactory().GetProtocol(requestReadTransport)) { TMessage message = protocol.ReadMessageBegin(); String methodName = message.Name; isOneWayMethod = ClientClassHasReceiveHelperMethod(methodName); return(isOneWayMethod); } } }
public override async Task WriteMessageBeginAsync(TMessage message, CancellationToken cancellationToken) { //trace start //TraceUtils.startLocalTracer("rpc.thrift start"); string methodName = message.Name; //TraceUtils.submitAdditionalAnnotation(Constants.TRACE_THRIFT_METHOD, methodName); TTransport transport = this.Transport; //string hostAddress = ((TSocket)transport).getSocket().getRemoteSocketAddress().toString(); //TraceUtils.submitAdditionalAnnotation(Constants.TRACE_THRIFT_SERVER, hostAddress); await base.WriteMessageBeginAsync(message, cancellationToken); //write trace header to field0 await WriteFieldZero(cancellationToken); }
//前科协代码 //将需要的代码都放在上面,日后将一下代码全部删除 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static TMessage AddMessage(int associationid, int createuserid, DateTime createtime, string content) { try { TMessage newMSG = new TMessage(); newMSG.AssociationId = associationid; newMSG.CreateTime = createtime; newMSG.CreateUserId = createuserid; newMSG.MessageContent = content; newMSG.IsDel = false; newMSG.Save(); return(newMSG); } catch { return(null); } }
public static Boolean RegisterMessageType <TMessage>() where TMessage : INetMessage, new() { var inst = new TMessage(); Type type = inst.GetType(); Int32 hash = GetNetworkCoreHash(type); if (netMessages.ContainsKey(hash)) { Log.Error("Tried to register a message type with a duplicate hash"); return(false); } else { netMessages[hash] = inst; return(true); } }
public void Write(Exception ex, TMessage type = TMessage.ExceptionWorkflow, string position = null) { if (this.Occur == null) { } else if ((type & TMessage.MaskException) == 0) { throw new ArgumentException("type should mask with TMessage.MaskException"); } else { string txt = string.Format("{0}: {1}", ex.GetType().Name, ex.Message); this.Occur(this, new EventArgsMessage { Text = txt, Type = type, Position = position }); } }
public override async Task WriteMessageBeginAsync(TMessage message, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (StrictWrite) { var version = Version1 | (uint)message.Type; await WriteI32Async((int)version, cancellationToken); await WriteStringAsync(message.Name, cancellationToken); await WriteI32Async(message.SeqID, cancellationToken); } else { await WriteStringAsync(message.Name, cancellationToken); await WriteByteAsync((sbyte)message.Type, cancellationToken); await WriteI32Async(message.SeqID, cancellationToken); } }
private void GetUser_Process(TMessage message, TProtocol iproto, Action <byte[]> callback) { var args = new Service1.GetUser_args(); try { args.Read(iproto); } catch (System.Exception ex) { iproto.Transport.Close(); callback(ThriftMarshaller.Serialize(new TMessage(message.Name, TMessageType.Exception, message.SeqID), new TApplicationException(TApplicationException.ExceptionType.Unknown, ex.Message))); return; } iproto.Transport.Close(); int seqID = message.SeqID; try { this._face.GetUser(args.UserId, (result) => { callback(ThriftMarshaller.Serialize(new TMessage("GetUser", TMessageType.Reply, seqID), new Service1.GetUser_result { Success = result })); }); } catch (System.Exception ex) { if (ex is Example.Service.Thrift.IllegalityUserIdException) { callback(ThriftMarshaller.Serialize(new TMessage("GetUser", TMessageType.Reply, seqID), new Service1.GetUser_result { Ex = ex as Example.Service.Thrift.IllegalityUserIdException })); return; } callback(ThriftMarshaller.Serialize(new TMessage(message.Name, TMessageType.Exception, message.SeqID), new TApplicationException(TApplicationException.ExceptionType.Unknown, ex.ToString()))); } }
public override async Task WriteMessageBeginAsync(TMessage message, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return; } await Trans.WriteAsync(new[] { ProtocolId }, cancellationToken).ConfigureAwait(false); await Trans.WriteAsync( new[] { (byte)((Version & VersionMask) | (((uint)message.Type << TypeShiftAmount) & TypeMask)) }, cancellationToken); var bufferTuple = CreateWriteVarInt32((uint)message.SeqID); await Trans.WriteAsync(bufferTuple.Item1, 0, bufferTuple.Item2, cancellationToken).ConfigureAwait(false); await WriteStringAsync(message.Name, cancellationToken).ConfigureAwait(false); }
public void WriteMessageBegin(TMessage message) { //保留真正的长度 缓存 this.Content.SetWriterIndex(0); if (this.StrictWrite) { uint version = VERSION_1 | (uint)(message.Type); WriteI32((int)version); WriteString(message.Name); WriteI32(message.SeqID); } else { WriteString(message.Name); WriteByte((sbyte)message.Type); WriteI32(message.SeqID); } }
public List <SavariWala.MapPoint> recv_getMapPoint() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } getMapPoint_result result = new getMapPoint_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); if (result.__isset.success) { return(result.Success); } throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "getMapPoint failed: unknown result"); }
public string recv_DownloadInnerXml() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } DownloadInnerXml_result result = new DownloadInnerXml_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); if (result.__isset.success) { return(result.Success); } throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "DownloadInnerXml failed: unknown result"); }
public List <string> recv_GetServerXmlList() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } GetServerXmlList_result result = new GetServerXmlList_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); if (result.__isset.success) { return(result.Success); } throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "GetServerXmlList failed: unknown result"); }
public CPopulationFitness recv_calculateSimPopulationFitness() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } calculateSimPopulationFitness_result result = new calculateSimPopulationFitness_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); if (result.__isset.success) { return(result.Success); } throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "calculateSimPopulationFitness failed: unknown result"); }
public Dictionary <int, Customer> recv_GetMap() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } GetMap_result result = new GetMap_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); if (result.__isset.success) { return(result.Success); } throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "GetMap failed: unknown result"); }
public int recv_Add() { TMessage msg = iprot_.ReadMessageBegin(); if (msg.Type == TMessageType.Exception) { TApplicationException x = TApplicationException.Read(iprot_); iprot_.ReadMessageEnd(); throw x; } Add_result result = new Add_result(); result.Read(iprot_); iprot_.ReadMessageEnd(); if (result.__isset.success) { return(result.Success); } throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "Add failed: unknown result"); }