public override void SetResult(Metadata metadata, ILetter letter, IReceivedEventArgs receivedEventArgs) { var result = _socket.Serializer.Deserialize <TResult>(letter.Parts[1], Type.GetType(metadata.Type)); Result = new Answerable <TResult>(_socket, result, receivedEventArgs.RemoteNodeId, metadata.ConversationId); _waitLock.Set(); }
private void TriggerOutstanding(Metadata metadata, ILetter letter, IReceivedEventArgs receivedEventArgs) { Outstanding outstanding; if (_outstandings.TryGetValue(metadata.ConversationId, out outstanding)) { outstanding.SetResult(metadata, letter, receivedEventArgs); _outstandings.Remove(metadata.ConversationId); } }
private void SocketOnReceived(ILetter letter, IReceivedEventArgs receivedEventArgs) { if (letter.Parts.Length != 2) { return; } var metadata = Serializer.Deserialize <Metadata>(letter.Parts[0]); Type messageType = Type.GetType(metadata.Type); if (messageType == null) { return; } TriggerOutstanding(metadata, letter, receivedEventArgs); TriggerRegistrations(messageType, metadata, letter, receivedEventArgs); }
private void TriggerRegistrations(Type type, Metadata metadata, ILetter letter, IReceivedEventArgs receivedEventArgs) { IEnumerable <Registration> registrations = GetMatchingRegistrations(type); foreach (Registration registration in registrations) { registration.Invoke(this, letter, metadata, type, receivedEventArgs); } }
public abstract void Invoke(TypedHyperSocket socket, ILetter letter, Metadata metadata, Type concreteType, IReceivedEventArgs receivedEventArgs);
public abstract void SetResult(Metadata metadata, ILetter letter, IReceivedEventArgs receivedEventArgs);
public override void Invoke(TypedHyperSocket socket, ILetter letter, Metadata metadata, Type concreteType, IReceivedEventArgs receivedEventArgs) { var message = _serializer.Deserialize <TMessage>(letter.Parts[1], concreteType); var answerable = new Answerable <TMessage>(_socket, message, receivedEventArgs.RemoteNodeId, metadata.ConversationId); _callback(socket, answerable); }
public override void Invoke(TypedHyperSocket socket, ILetter letter, Metadata metadata, Type concreteType, IReceivedEventArgs receivedEventArgs) { var message = _serializer.Deserialize <TMessage>(letter.Parts[1], concreteType); var answerable = new Answerable <TMessage>(_socket, message, receivedEventArgs.RemoteNodeId, metadata.ConversationId); ITypedHandler <TMessage> handler = _handlerFactory.CreateHandler <THandler, TMessage>(message); handler.Execute(_socket, answerable); }