Ejemplo n.º 1
0
        public override Task InvokeConnectionAsync(string connectionId, string methodName, object[] args)
        {
            var connection = _connections[connectionId];

            var invocationAdapter = _registry.GetInvocationAdapter(connection.Metadata.Get <string>("formatType"));

            var message = new InvocationDescriptor
            {
                Method    = methodName,
                Arguments = args
            };

            return(invocationAdapter.WriteInvocationDescriptorAsync(message, connection.Channel.GetStream()));
        }
Ejemplo n.º 2
0
        private Task InvokeAllWhere(string methodName, object[] args, Func <Connection, bool> include)
        {
            var tasks   = new List <Task>(_connections.Count);
            var message = new InvocationDescriptor
            {
                Method    = methodName,
                Arguments = args
            };

            // TODO: serialize once per format by providing a different stream?
            foreach (var connection in _connections)
            {
                if (!include(connection))
                {
                    continue;
                }

                var invocationAdapter = _registry.GetInvocationAdapter(connection.Metadata.Get <string>("formatType"));

                tasks.Add(invocationAdapter.WriteInvocationDescriptorAsync(message, connection.Channel.GetStream()));
            }

            return(Task.WhenAll(tasks));
        }
Ejemplo n.º 3
0
 public Task WriteInvocationDescriptorAsync(InvocationDescriptor invocationDescriptor, Stream stream)
 {
     Write(invocationDescriptor, stream);
     return(Task.FromResult(0));
 }