使用Apache Thrift进行服务多路复用(Service Multiplexing using Apache Thrift)
服务器代码:
TMultiplexedProcessor processor = new TMultiplexedProcessor(); processor.registerProcessor( "AddService", new AddService.Processor(new AddHandler())); processor.registerProcessor( "MultiplyService", new MultiplyService.Processor(new MultiplyHandler())); TServerTransport serverTransport = new TServerSocket(7911); TSimpleServer server = new TSimpleServer(new TSimpleServer.Args(serverTransport). processor(processor)); System.out.println("Starting server on port 7911 ..."); server.serve();
客户代码:
TFramedTransport transport; transport = new TFramedTransport(new TSocket("localhost", 7911)); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); System.out.println("1"); TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "AddService"); AddService.Client service = new AddService.Client(mp); System.out.println("2"); TMultiplexedProtocol mp2 = new TMultiplexedProtocol(protocol, "MultiplyService"); MultiplyService.Client service2 = new MultiplyService.Client(mp2); System.out.println("3"); System.out.println(service.add(2,2)); System.out.println(service2.multiply(2000,200));
但是当我运行服务器(侦听端口7911)和客户端时,客户端不处理对add / multiply函数的最后两次调用。
我可以调试参数已发送到服务器,但服务器无法处理它们。
关于我缺少什么的任何指示?
Server code:
TMultiplexedProcessor processor = new TMultiplexedProcessor(); processor.registerProcessor( "AddService", new AddService.Processor(new AddHandler())); processor.registerProcessor( "MultiplyService", new MultiplyService.Processor(new MultiplyHandler())); TServerTransport serverTransport = new TServerSocket(7911); TSimpleServer server = new TSimpleServer(new TSimpleServer.Args(serverTransport). processor(processor)); System.out.println("Starting server on port 7911 ..."); server.serve();
Client Code:
TFramedTransport transport; transport = new TFramedTransport(new TSocket("localhost", 7911)); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); System.out.println("1"); TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "AddService"); AddService.Client service = new AddService.Client(mp); System.out.println("2"); TMultiplexedProtocol mp2 = new TMultiplexedProtocol(protocol, "MultiplyService"); MultiplyService.Client service2 = new MultiplyService.Client(mp2); System.out.println("3"); System.out.println(service.add(2,2)); System.out.println(service2.multiply(2000,200));
But when I am running the server(listening on port 7911) and the client, the client doesnt process the last two calls to the add/multiply functions.
I could debug that the arguments have been sent to the server, but the server is not able to process them.
Any pointers as to what i am missing?
原文:https://stackoverflow.com/questions/19614648
最满意答案
这是你想要的JSFiddle: https ://jsfiddle.net/3qypL8gb/
我删除了你的
<a>
标签,因为有人在评论中说他们不能成为<ul>
直接孩子而且你无论如何都没有做任何事。我利用了你想删除的单词是
<li>
中的最后一个文本。 我存储了html的长度,然后存储了文本的长度,并创建了html.length - text.length的子字符串。然后我用新的子字符串替换了
<li>
html。Here is a JSFiddle of what you want: https://jsfiddle.net/3qypL8gb/
I removed your
<a>
tags because as someone said in the comments they cannot be direct child of a<ul>
and you weren't doing anything with them anyway.I took advantage of how the words you wanted to remove were the last text in the
<li>
. I stored the length of the html and then stored the length of the text and made a substring of the html.length - text.length.I then replaced the
<li>
html with that new substring.
相关问答
更多-
我们如何删除span标记而不会使用jquery丢失数据?(How do we remove the span tag without lossing data using jquery?)[2021-08-03]
这将做到这一点: $('ul li a').html($('ul li a').text()); 使用$('ul li a').text()选择标签中的所有文本节点。 使用$('ul li a').html()将所有选定的文本节点放入您的标记中。 这导致从那里剥离所有标签。 对于多个LI,你可以使用这个: $('ul.sub-menu > li.menu-item > a').each(function(){ $(this).html($(this).text()); }); This will d ... -
from bs4 import BeautifulSoup html = """
- Name Piter
- ...
-
例如,使用您自己的类和ovverride renderMenuItem扩展CMenu protected function renderMenuItem($item) { $html = parent::renderMenuItem($item) if(isset($item['highlighter'])) { $html = "$html" } return $html; } 并 ...
-
span标签内的span标签(html span tag within span tag)[2023-03-10]
好的,可以。 没有禁止的规则,也不鼓励这种做法。 如果这段HTML出现多次,请用class="tprice"替换id="tprice" class="tprice" ,因为ID只能出现一次。 Yes, it's OK. There's no rule which forbids, nor discourages this practice. If that piece of HTML occurs more than once, replace id="tprice" by class="tprice", ... -
如何使用jscript删除菜单中span标记的最后一个元素?(How can i remove last element of span tag in menu using jscript?)[2022-11-10]
使用jQuery? $("li span:last").remove(); 或者像Pointy指出的那样,不要把它放在首位。 using jQuery? $("li span:last").remove(); or like Pointy pointed out, just don't place it there in the first place. -
尝试这个: $("ul li a").after(""); 这里的例子。 Try this: $("ul li a").after(""); Example here.
-
如何在不影响我的span标记的情况下删除li标签的值(How to remove the value of my li tag without affecting my span tag)[2022-02-15]
这是你想要的JSFiddle: https ://jsfiddle.net/3qypL8gb/ 我删除了你的标签,因为有人在评论中说他们不能成为- 直接孩子而且你无论如何都没有做任何事。 我利用了你想删除的单词是
- 中的最后一个文本。 我存储了html的长度,然后存储了文本的长度,并创建了html.length - text.length的子字符串。 然后我用新的子字符串替换了
- html。 Here is a JSFiddle of what you want: https://jsf ...
-
如何从ul中删除所有li?(How to remove all li from ul?)[2022-09-28]
在您的方案中,您要删除html元素。 因此,首先将选择器定义为html元素,即- 然后使用JS文件中的tagClass 。 JS angular.forEach(angular.element('.tagClass'),function(value,key){ var data = angular.element(value); data.remove(); }); In your ...
-
向anchor添加click event handler ,而不是编写内联函数,如下所示: $('.ach').on('click', function() { $('li').removeClass('active'); $(this).closest('li').addClass('active'); }); .detail-sidemenu li a:hover { background-color: #ed1b23; color: #ffffff; } .active ...
-
$("li span:has(a)").after("
"); 现场演示: http : //jsfiddle.net/LkeVE/1 $("li span:has(a)").after("
"); Live Demo: http://jsfiddle.net/LkeVE/1