Передача длинной строки из SignalR IHubProxy

Я хочу передать поток байтов от IHubProxy другому клиенту. Я передаю поток байтов в виде строки. Я смог передать небольшой текст без каких-либо проблем. Но когда я передаю большую строку (которая представляет собой изображение, преобразованное в поток байтов и в строку), я не могу передать строку. Как я могу передать большую строку?

        string username = Console.ReadLine();

        var connection = new HubConnection("http://localhost:51428/");
        IHubProxy myHub = connection.CreateHubProxy("ScannerHub"); //This should be same as Hub Name

        //Establishing the connection
        connection.Start().ContinueWith(task =>
        {
            if (task.IsFaulted)
            {
                Console.WriteLine("Failed to start: {0}", task.Exception.GetBaseException());
            }
            else
            {
                Console.WriteLine("Success! Connected with client connection id {0}", connection.ConnectionId);

                //After connection is established. Register the printer client with client information
                myHub.Invoke("RegisterClient", username, connection.ConnectionId, "Printer").ContinueWith(task2 =>
                {
                    if (task2.IsFaulted)
                    {
                        Console.WriteLine("An error occurred during the method call {0}", task2.Exception.GetBaseException());
                    }
                    else
                    {
                        Console.WriteLine("Successfully Registred");
                    }
                });

                //In the client (here it is Printer Client) there is a method named getScanRequest
                //This method retrieves the scan request and processes it accordingly.
                //What is done here is that, in the HubProxy we listen to the calls on current clients 
                //getScanRequest been hit. If hit. Execute that method.

                //Use a Func when you want to return a value
                //http://stackoverflow.com/questions/4317479/func-vs-action-vs-predicate

                //Func<string, byte[]> scanFunction;
                //scanFunction = Scan;

                //Action<string> printFunction;
                //printFunction = Scan;

                //myHub.On("getScanRequest", data => Console.WriteLine("Got Print Request " + data));
                //Register on a server side method with a callback function
                //myHub.On("getScanRequest", printFunction);
                //myHub.On("getScanRequest", data => Console.WriteLine("got print request from "+data));

                myHub.On<string>("getScanRequest", (clientUrl) =>
                    {
                        string scanByteStream = Scan(clientUrl);
                        try
                        {
                            myHub.Invoke("GetValueFromScanner", scanByteStream);
                        }
                        catch (Exception ex)
                        {
                            var j = 0;
                        }
                    });
            }

person Nipuna    schedule 09.08.2013    source источник
comment
Насколько велика эта строка? Посмотрите на этот вопрос: stackoverflow.com/questions /18012863/   -  person Stephen    schedule 09.08.2013
comment
я смог передавать файлы размером до 100 МБ с помощью SignalR, это в основном зависит от памяти клиента, так как при 200 МБ и выше я получал исключение из памяти, когда зарезервированная память клиента достигала 1,2 ГБ, поэтому мне пришлось изменить способ отправки файлов (для WCF), поэтому я думаю, что лучше сохранить размер до рекомендуемого предела, как указано в ответе в комментарии Стивена.   -  person Mahmoud Darwish    schedule 11.08.2013
comment
Я думаю, вам нужно разбить текст на куски.   -  person RredCat    schedule 21.09.2015