Re: SocketFactory Server communication between sessions
Rocco Caputo <[email protected]> Wed, 17 Oct 2012 10:18:48 -0400
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <[email protected]> |
On Oct 12, 2012, at 09:16, Ty Roden wrote: >=20 > The server code, once modified seems to be doing most of what I need, = as > clients can connect, and I can properly respond to events coming down = the > line from clients. In place of the 'echo back anything the client = sends > you' I am examining the data, and responding to it with what I need = and all > seems to be well. The problem is that I have one client that connects = that > sends me data that I need to make sure reaches the other clients so = that > they can process the data arriving. I can accept and process the data = from > this master client, but I cannot find how I might send the data to = each > running process to in turn have their sessions react to the data = arriving. > Since it is a client session just like any other that is receiving the > data, even saving down the session IDs into a hash I am having an = issue > sending data across to the other sessions. Perhaps this just means = that I > am going about this wrong. http://poe.perl.org/?POE_Cookbook/Chat_Server seems to do what you want. = Whenever one client sends data, it's broadcast to all others. It uses = a shared hash to register clients and a global helper function to = iterate the hash and broadcast messages. Of course your version of broadcast() can do more complex calculations = and determine which other clients will receive the results. Your shared = hash can also contain a lot more information for each client. And since = it's shared, any client can inspect it at will... without pesky message = passing among clients. If a shared hash and accessor functions doesn't feel right, consider = abstracting it into a singleton class or object, and give every client = the package name or instance to the object. I think this covers all your other questions. Please let us know if it = doesn't. Thanks! --=20 Rocco Caputo <[email protected]>