Hello fellow Monks. I have what seems like a very simple question. I am fairly new to POE, but I quite like what I have seen so far. I have a POE::Component::Server::TCP session set up and working. It spews out new client sessions just like it's supposed to, and everything seems to be working great.

The only thing is, I'd like to have a nice way to broadcast a message to all current clients. I currently do this with a plain old subroutine, which when called iterates through the currently connected users and puts the message. This works fine, but I think it would be nice to have a broadcast state on the P::C::S::TCP server session that does the same thing.

Now, I know about the InlineStates, PackageStates, and ObjectStates elements in the constructor, but this only adds these states to the client sessions. I want to add a state to the server session. I also know about $kernel->state(...), but again I have the same problem. One can only modify the states of the active session, and I cannot find a place to add any code to P::C::S::TCP's server session (i.e. I cannot run $kernel->state(...) when the server session is active). Perhaps there is something I am overlooking in the documentation, but I just can't seem to find anything.

Any help would be greatly appreciated.


In reply to adding a state to the server session with POE::Component::Server::TCP by revdiablo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.