public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink) { var methodCallMessage = (IMethodCallMessage)msg; try { ITransportHeaders requestHeaders; Stream requestStream; SerializeRequestMessage(methodCallMessage, out requestHeaders, out requestStream); var sinkStack = new ClientChannelSinkStack(replySink); sinkStack.Push(this, methodCallMessage); this._nextChannelSink.AsyncProcessRequest(sinkStack, methodCallMessage, requestHeaders, requestStream); } catch (Exception ex) { var errorMessage = new ReturnMessage(ex, methodCallMessage); if (replySink != null) { replySink.SyncProcessMessage(errorMessage); } } return null; }
///<summary> /// Creates a DLT. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public DLT(IMessage message, string description) : base(message, description){ data = new IType[4]; data[0] = new NR(message,"Range"); data[1] = new NM(message,"Numeric threshold"); data[2] = new ST(message,"Change computation"); data[3] = new NM(message,"Length of time-days"); }
public override void IncrementCountAsync(IMessage<Bond.Void> param) { lock (IncrementLock) { Count++; } }
protected override void Process(IMessage input, Action<IMessage> continueWith, Action<FlowRuntimeException> unhandledException) { if (input is ActivationMessage) _continueWith = continueWith; else _translator.Process_local_output(input); }
// NMS Message AMQP Message // ================================ ================= // string NMSCorrelationID string CorrelationId // MsgDeliveryMode NMSDeliveryMode bool Durable // IDestination NMSDestination // string MNSMessageId string MessageId // MsgPriority NMSPriority byte Priority // bool NMSRedelivered bool Redelivered // IDestination NMSReplyTo Address ReplyTo // DateTime NMSTimestamp // TimeSpan NMSTimeToLive Duration Ttl // string NMSType string ContentType // IPrimitiveMap Properties Dictionary Properties // string Subject // string UserId // public virtual Message ToAmqpMessage(IMessage message) { Message amqpMessage = CreateAmqpMessage(message); if (null != message.NMSCorrelationID) { amqpMessage.CorrelationId = message.NMSCorrelationID; } amqpMessage.Durable = (message.NMSDeliveryMode == MsgDeliveryMode.Persistent); if (null != message.NMSMessageId) { amqpMessage.MessageId = message.NMSMessageId; } amqpMessage.Priority = ToAmqpMessagePriority(message.NMSPriority); amqpMessage.Redelivered = message.NMSRedelivered; if (null != message.NMSReplyTo) { amqpMessage.ReplyTo = ToAmqpAddress(message.NMSReplyTo); } if (message.NMSTimeToLive != TimeSpan.Zero) { amqpMessage.Ttl = ToQpidDuration(message.NMSTimeToLive); } if (null != message.NMSType) { amqpMessage.ContentType = message.NMSType; } amqpMessage.Properties = FromNmsPrimitiveMap(message.Properties); // TODO: NMSDestination, Amqp.Subect, Amqp.UserId return amqpMessage; }
private static void SerDesMessage(IMessage message) { var b = CustomFormatter.Serialize(message); var o = CustomFormatter.Deserialize(b); Assert.AreEqual(o.GetType(), message.GetType()); AreEqual(message, o); }
///<summary> /// Creates a TS. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public TS(IMessage message, string description) : base(message, description) { data = new IType[2]; data[0] = new TSComponentOne(message,"Time of an event"); data[1] = new ST(message,"Degree of precision"); }
///<summary> /// Creates a CM_RANGE. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public CM_RANGE(IMessage message, string description) : base(message, description) { data = new IType[2]; data[0] = new CE(message,"Low Value"); data[1] = new CE(message,"High Value"); }
protected override void HandleRequestMessage(IMessage message, ReplyMessageHolder replyHolder) { object result = SplitMessage(message); if(result == null) { return; } object correlationId = message.Headers.Id; if(result is ICollection) { ICollection items = (ICollection)result; int sequenceNumber = 0; int sequenceCount = items.Count; foreach(object item in items) { AddReply(replyHolder, item, correlationId, ++sequenceNumber, sequenceCount); } } else if(result.GetType().IsArray) { object[] items = (object[])result; int sequenceNumber = 0; int sequenceSize = items.Length; foreach(object item in items) { AddReply(replyHolder, item, correlationId, ++sequenceNumber, sequenceSize); } } else { AddReply(replyHolder, result, correlationId, 1, 1); } }
void SendReadyMessage(bool startup) { if (ControlQueue == null) return; IMessage[] messages; if (startup) { messages = new IMessage[EndpointTransport.NumberOfWorkerThreads]; for (var i = 0; i < EndpointTransport.NumberOfWorkerThreads; i++) { var rm = new ReadyMessage { ClearPreviousFromThisAddress = (i == 0) }; messages[i] = rm; } } else { messages = new IMessage[] {new ReadyMessage()}; } EndpointBus.Send(ControlQueue, messages); }
public override IMessage Invoke(IMessage msg) { var mcm = msg as IMethodCallMessage; if (mcm == null) return null; if (IsEqualsCall(mcm)) return ReturnValue(HandleEquals(mcm), mcm); if (IsGetHashCodeCall(mcm)) return ReturnValue(GetHashCode(), mcm); if (IsGetTypeCall(mcm)) return ReturnValue(GetProxiedType(), mcm); if (IsToStringCall(mcm)) { var type = GetProxiedType(); var hashCode = GetHashCode(); var value = string.Format("RemotingMock_{0}<{1}>", hashCode, type.Name); return ReturnValue(value, mcm); } var invocation = new RemotingInvocation(this, mcm); interceptor.Intercept(invocation); return ReturnValue(invocation.ReturnValue, invocation.Arguments, mcm); }
///<summary> /// Creates a SN. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public SN(IMessage message, string description) : base(message, description){ data = new IType[4]; data[0] = new ST(message,"Comparator"); data[1] = new NM(message,"Num1"); data[2] = new ST(message,"Separator or suffix"); data[3] = new NM(message,"Num2"); }
public Stream GetResponseStream (IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers) { return null; }
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary> /// <param name="other">An object to compare with this object.</param> /// <returns>true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.</returns> public bool Equals(IMessage other) { bool result = other.DateTime == DateTime && other.From == From && other.To == To && other.MessageText == MessageText; return result; }
///<summary> /// Creates a PTA. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public PTA(IMessage message, string description) : base(message, description){ data = new IType[4]; data[0] = new IS(message, 147,"Policy Type"); data[1] = new IS(message, 193,"Amount Class"); data[2] = new NM(message,"Money or Percentage Quantity"); data[3] = new MOP(message,"Money or Percentage"); }
// Messages will be intercepted here and redirected // to another object. public override IMessage Invoke (IMessage msg) { try { if (msg is IConstructionCallMessage) { IActivator remActivator = (IActivator) RemotingServices.Connect (typeof (IActivator), "tcp://localhost:1234/RemoteActivationService.rem"); IConstructionReturnMessage crm = remActivator.Activate ((IConstructionCallMessage) msg); return crm; } else { methodOverloaded = RemotingServices.IsMethodOverloaded ((IMethodMessage) msg); _mthBase = RemotingServices.GetMethodBaseFromMethodMessage ((IMethodMessage) msg); MethodCallMessageWrapper mcm = new MethodCallMessageWrapper ((IMethodCallMessage) msg); mcm.Uri = RemotingServices.GetObjectUri ((MarshalByRefObject) target); MarshalByRefObject objRem = (MarshalByRefObject) Activator.CreateInstance (GetProxiedType ()); RemotingServices.ExecuteMessage ((MarshalByRefObject) objRem, (IMethodCallMessage) msg); IMessage rtnMsg = null; try { rtnMsg = _sink.SyncProcessMessage (msg); } catch (Exception e) { Console.WriteLine (e.Message); } Console.WriteLine ("RR:" + rtnMsg); return rtnMsg; } } catch (Exception ex) { Console.WriteLine (ex); return null; } }
///<summary> /// Creates a QSC. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public QSC(IMessage message, string description) : base(message, description){ data = new IType[4]; data[0] = new ST(message,"Name of field"); data[1] = new ID(message, 0,"Relational operator"); data[2] = new ST(message,"Value"); data[3] = new ID(message, 0,"Relational conjunction"); }
/// <summary> /// Returns true if the message return value is marked as NonCompressible. /// </summary> /// <param name="msg">Message to check.</param> public static bool IsCompressionExempt(IMessage msg) { if (msg != null && msg.Properties.Contains("__Return")) { var obj = msg.Properties["__Return"]; if (obj == null) { return false; } if (obj.GetType().IsDefined(typeof(NonCompressibleAttribute), false)) { return true; } if (obj is ICompressible) { if (((ICompressible)obj).PerformCompression == false) { return true; } } } return false; }
protected void SendMessageToGatewayQueue(IMessage messageToSend) { transportMessage = null; messageReceived = new ManualResetEvent(false); bus.Send("gateway", messageToSend); }
public void Process(IMessage message) { if (IsFlowInputMessage(message)) { // parent/flow.port => flow/.port var output = new Message(Port.Build(message.Port.OperationName, "", message.Port.Name), message.Data, message.CorrelationId) { Causalities = message.Causalities, FlowStack = message.FlowStack }; if (message.Port.Path != "") output.FlowStack.Push(message.Port.Path); Result(output); } else { // flow/.port => parent/flow.port var parentFlowname = ""; if (!message.FlowStack.IsEmpty) parentFlowname = message.FlowStack.Pop(); var output = new Message(Port.Build(parentFlowname, Create_operation_name(message), message.Port.Name), message.Data, message.CorrelationId) { Causalities = message.Causalities, FlowStack = message.FlowStack }; Result(output); } }
//-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * @override * * Overriding the handleMessage method to respond to the * editInExcel message. */ public override void HandleMessage(IMessage message) { if (ExcelMessage.EDIT_IN_EXCEL == message.type) { ExcelMessage excelMessage = (ExcelMessage)message; // Note: Excel rows/cols start at 1 not 0 int rowIdx = 1; int colIdx = 1; // Iterate the data set from Flex foreach (object[] arr in excelMessage.cellData) { // Start inserting at the first col for each value colIdx = 1; foreach (Object val in arr) { ExcelProxy.SetCell(rowIdx, colIdx, val.ToString()); colIdx++; } rowIdx++; } ExcelProxy.SetExcelVis(true); } }
///<summary> /// Creates a VR. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public VR(IMessage message, string description) : base(message, description) { data = new IType[2]; data[0] = new ST(message,"First Data Code Value"); data[1] = new ST(message,"Last Data Code Value"); }
public Stream GetRequestStream(IMessage requestMsg, ITransportHeaders requestHeaders) { // parameters validation if (requestHeaders == null) throw new ArgumentNullException("requestHeaders"); IMethodCallMessage methodCall = requestMsg as IMethodCallMessage; if (methodCall == null) throw new NotSupportedException(); if (_connection != null) { // close connection as it is probably not valid _connection.Close(); } // get connection from the cache _connection = _connectionCache.GetConnection(_channelUri); try { // return stream for writing request return _connection.GetRequestStream(methodCall, requestHeaders); } catch { // close connection as it is probably not valid _connection.Close(); _connection = null; throw; } }
void IMutateOutgoingTransportMessages.MutateOutgoing(IMessage[] messages, TransportMessage transportMessage) { if (transportMessage.Headers.ContainsKey(WindowsIdentityName)) transportMessage.Headers.Remove(WindowsIdentityName); transportMessage.Headers.Add(WindowsIdentityName, Thread.CurrentPrincipal.Identity.Name); }
public void DispatchReplyMessage(IMessage msg) { if (this._replySink != null) { this._replySink.SyncProcessMessage(msg); } }
public Result Post(IMessage message) { try { var request = WebRequest.Create(message.Url) as HttpWebRequest; request.Method = "POST"; foreach (string key in message.Headers.Keys) { var value = message.Headers[key]; if (key == "content-type") { request.ContentType = value; continue; } request.Headers.Add(key, value); } request.Headers.Add("submitted", this.TimeProvider.GetEpochInMilliSeconds(DateTimeKind.Utc).ToString(CultureInfo.InvariantCulture)); return this.RequestAndRespond(request, message.Body); } catch (Exception) { return Result.PermanentError; } }
public Stream GetResponseStream (IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers) { throw new NotImplementedException(); }
public static ErrorReply For(IMessage message) { return new ErrorReply { ReplyFor = message.Id }; }
public UiMessage(IMessage message, Contact contact) { Address = message.Address; Text = message.Text; TimeStamp = message.TimeStamp; Contact = contact; }
public void Broadcast(IMessage message) { if (IsEnabled) { ThreadPool.QueueUserWorkItem(SendTweet, message.GetMessage(140)); } }
public MessageContext(IMessage message, string key) : this(message) { Key = key; }
internal static SmsPacket GroupPacket(IMessage message) { var sequenceId = CmppTools.GetHeadSequenceId(); return(GroupPacket(message, sequenceId)); }
/// <summary> /// Creates a parser that returns the specified message. /// </summary> /// <typeparam name="TResult">The type of result of the parser.</typeparam> /// <typeparam name="TToken">The type of tokens.</typeparam> /// <param name="parser">The parser.</param> /// <param name="message">The message; or <see langword="null"/> to specify none.</param> /// <returns>The created parser.</returns> public static Parser <TResult, TToken> WithMessage <TResult, TToken>(this Parser <TResult, TToken> parser, [CanBeNull] IMessage message) { #region Contract if (parser == null) { throw new ArgumentNullException(nameof(parser)); } #endregion IParseResult <TResult, TToken> Parser(ITokenStream <TToken> input) { #region Contract if (input == null) { throw new ArgumentNullException(nameof(input)); } #endregion return(parser(input) .WithMessage(message)); } return(Parser); }
public EmptyMessageContext(IMessage message) { SentTime = DateTime.Now; Message = message; MessageID = message.ID; }
private void OnReceiveCustomMessageHandler(IMessage sMessage) { Debug.Log((sMessage as MyCustomMessage).MyCustomString); }
/// <summary> /// 消息接收者 /// </summary> /// <param name="sMessage"></param> private void OnReceiveMessageHandler(IMessage sMessage) { Debug.Log(sMessage.Data.ToString()); }
public MessageContext(IMessage message, string replyToEndPoint, string key) : this(message, key) { ReplyToEndPoint = replyToEndPoint; }
/// <summary> Creates a CM_RANGE. </summary> /// /// <param name="message"> The Message to which this Type belongs. </param> public CM_RANGE(IMessage message) : this(message, null) { }
public void Reply(IMessage response) { _messageContext.ReplyResponse = response; }
/// <summary> Creates a CM_RANGE. </summary> /// /// <param name="message"> The Message to which this Type belongs. </param> /// <param name="description"> The description of this type. </param> public CM_RANGE(IMessage message, string description) : base(message, description) { data = new IType[2]; data[0] = new CE(message, "Low Value"); data[1] = new CE(message, "High Value"); }
private void Closed(IMessage message) { FireClosed(); }
public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink) { return(nextSink.AsyncProcessMessage(msg, replySink)); }
///<summary> /// Creates a CM_VR. /// <param name="message">The Message to which this Type belongs</param> /// <param name="description">The description of this type</param> ///</summary> public CM_VR(IMessage message, string description) : base(message, description) { data = new IType[2]; data[0] = new ST(message, "First data code value"); data[1] = new ST(message, "Last data code calue"); }
private void Error(IMessage error) { var err = new OnErrorArgs(this.XSocketClient.Serializer.DeserializeFromString <Exception>(error.Data)); this.Error(err); }
public void SendRequest(uint serviceHash, uint methodId, IMessage request, Action <CodedInputStream> callback) { _responseCallbacks[_requestToken] = callback; SendRequest(serviceHash, methodId, request); }
public void Add(IMessage message) { messages = messages ?? new List <IMessage>(); messages.Add(message); }
public Task UpdateReportedPropertiesAsync(IMessage reportedPropertiesMessage) { return(this.cloudProxyDispatcher.UpdateReportedPropertiesAsync(this.identity, reportedPropertiesMessage, this.twinNeedsSubscribe.GetAndSet(false))); }
///<summary> /// Creates a CM_VR. /// <param name="message">The Message to which this Type belongs</param> ///</summary> public CM_VR(IMessage message) : this(message, null) { }
protected override IServerMessageEnvelope CreateEnvelope(IDictionary <string, object> metadata, IMessage message) { return(EmbeddedMessageEnvelope.Create(metadata, message)); }
/// <summary> /// Used as a recurring method which will remove old posts to keep the output channel clean of expired raids. /// </summary> /// <param name="stateInfo"></param> public async Task PurgePosts() { try { var now = DateTime.Now; int remaining = 0, deleted = 0; foreach (var guild in bot.Guilds) { var deletedPosts = new List <PokemonRaidPost>(); var posts = Config.GetServerConfig(guild.Id, ChatTypes.Discord).Posts; foreach (var post in posts) { if (post.EndDate < now) { deletedPosts.Add(post); deleted++; } else { remaining++; } } foreach (var post in deletedPosts) { posts.Remove(post); var messages = new List <IMessage>(); if (post.OutputMessageId != default(ulong)) { var outputChannel = GetChannel(post.OutputChannelId); try { var m = new IMessage[] { await outputChannel.GetMessageAsync(post.OutputMessageId) }; messages.AddRange(m.Where(x => x != null)); } catch (Exception e) { DoError(e); } try { if (messages.Count() > 0) { await outputChannel.DeleteMessagesAsync(messages); } } catch (Exception e) { DoError(e); } } foreach (var channelMessage in post.ChannelMessages) { var fromChannel = GetChannel(channelMessage.Key); if (channelMessage.Value.MessageId != default(ulong)) { var m1 = new IMessage[] { await fromChannel.GetMessageAsync(channelMessage.Value.MessageId) }; if (m1.Count() > 0 && m1[0] != null) { try { if (m1[0] is SocketUserMessage && ((SocketUserMessage)m1[0]).IsPinned) { await((SocketUserMessage)m1[0]).UnpinAsync(); } await m1[0].DeleteAsync(); } catch (Exception e) { DoError(e); } } else { } } } } } Config.Save(); await Logger.Log(new LogMessage(LogSeverity.Debug, "Handler", string.Format("deleted:{0}; remaining:{1}", deleted, remaining))); } catch (Exception e) { DoError(e); } }
public Task <AsyncTaskResult> HandleAsync(IMessage message) { return(_handler.HandleAsync(message as T)); }
public Task SendMessageAsync(IMessage message) => this.cloudProxyDispatcher.SendMessageAsync(this.identity, message);
public IMessage Send(IMessage Message) { var retval = new TextMessage("Error.OK"); return(retval); }
public CorrelationDataWrapper(string id, object userData, IMessage message) : base(id) { UserData = userData; Message = message; }
public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink) { this.lease.RenewOnCall(); return(this.nextSink.AsyncProcessMessage(msg, replySink)); }
public static async Task DelayedDelete(this IMessage message, TimeSpan delay) { await Task.Delay(delay); await message.DeleteAsync(); }
public async ValueTask <bool> CallAsync(IMessageScope scope, IMessageHandlerFactory handlerFactory, IMessage message, IRichMessageDescriptor messageDescriptor, List <Exception> exceptions = null, CancellationToken cancellationToken = default) { var handlerDescriptor = handlerFactory.GetHandlerDescriptor(); IMessageHandler handler = null; try { handler = handlerFactory.GetHandler(scope); if (handlerDescriptor.IsAsync) { await GetOrCreateAsyncHandlerCallCache(handlerDescriptor).Invoke(handler, message, messageDescriptor); } else { GetOrCreateSyncHandlerCallCache(handlerDescriptor).Invoke(handler, message, messageDescriptor); } } catch (TargetInvocationException e) { exceptions?.Add(e.InnerException); return(false); } catch (Exception e) { exceptions?.Add(e); return(false); } finally { if (handler != null) { handlerFactory.ReleaseHandler(scope, handler); } } return(true); }
public void Send(string destination, IMessage message, IMessageSender ms) { SendMessage("id", destination, message, ms); }
public byte[] Serialize(IMessage message) { return(Encoding.UTF8.GetBytes(message.Payload.ToString())); }
public IMessage SyncProcessMessage(IMessage msg) { this.lease.RenewOnCall(); return(this.nextSink.SyncProcessMessage(msg)); }