简体   繁体   English

如何使用SOAP处理多个客户端?

[英]How to handle multiple client with SOAP?

I'm having two clients from PHP calling ac/c++ function getNumber(); 我有两个来自PHP的客户端,调用ac / c ++函数getNumber();。 repeatly, and from c server it generate a number one at a time. 反复地,它从c服务器一次生成一个数字。 now what it does is each generated number can be recieved from on client only and the rest will recieve the next generated number. 现在它所做的是只能从客户端上接收每个生成的号码,其余的将接收下一个生成的号码。 for example 例如

client A and B. 客户A和B。

generated number: 1,2,3,4,5,6,7,8,9 生成的数字:1,2,3,4,5,6,7,8,9

client A will finally recieved 1,3,5,7,9 and B will recieved 2,4,6,8 客户A最终将收到1,3,5,7,9,而B将收到2,4,6,8

How can I create a function that A and B can recieved all generated number? 如何创建A和B可以接收所有生成数字的函数?

What if there are ten or thousand clients? 如果有十万个客户怎么办?

Thanks 谢谢

There are 2 ways that I can think of that you can approach this. 我认为有两种方法可以解决此问题。

First of you can structure your server so that it remembers some state information about each client, given that your using SOAP you'll probably have to add some kind of unique id token to the message, possibly genenerated by the server on the first call from the client (or a call with no such id token). 首先,您可以对服务器进行结构设计,使其记住有关每个客户端的一些状态信息,考虑到使用SOAP,您可能必须向消息中添加某种唯一的id令牌,可能是服务器在第一次调用时生成的客户(或没有此类ID令牌的呼叫)。 and then maintain a state database in the server that allows you to process each call. 然后在服务器中维护一个状态数据库,使您可以处理每个呼叫。

Second way may not be appropriate but if the next value in your sequence can be determined from the previous value then make each client provide the previous value as part of the next call. 第二种方法可能不合适,但是如果可以从前一个值中确定序列中的下一个值,则让每个客户端在下一次调用中提供前一个值。 You'd need to define some special starting value that indicates that this is a new client. 您需要定义一些特殊的起始值,以指示这是一个新客户端。

Method 1 has the advanatge of working with any type of data but at the cost of needing a database of state information to be held at the server, and if you need the server to be restartable the data would have to be persisted. 方法1的优点是可以处理任何类型的数据,但是需要在服务器上保存状态信息数据库,而如果需要服务器可重新启动,则必须保留数据。

Method 2 puts less demands on the server but won't work for all data sequences. 方法2对服务器的需求较少,但不适用于所有数据序列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM