User Tag List

Results 1 to 4 of 4

Thread: How do I send a message to every client?

  1. #1
    No Products Registered

    Join Date
    Jan 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I send a message to every client?

    Hi forums,

    I'm encountering a lot of frustration here...I'm trying to have one player send a message to the server. The server will then, in turn, send this message to all the clients. I can't get this simple thing to work.

    in Fusion my code is as follows

    -upon pressing 'p'
    +Send text "One" to server on subchannel 8

    -On Text Server Message on subchannel 8 (sent)
    +End the application

    in python:

    if message.subchannel == 8:
    self.sendMessage("Whatever", 8)


    The self in the python code is the server. I've built this off the example code from Mathias's account server. I would assume that the server is sending this message out to everyone logged in, but this results in only the player who sent the message to receive it (and thus end the application).

    Oddly enough, I have similar setups in other parts of my code that seem to work fine. Why isn't this working? Did I find a bug?

    Thanks in advance for the help...

  2. #2
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I send a message to every client?

    Well, I've never used POINC before but to me it looks like you've just explained the bug to yourself.

    In the receive handler for the individual client, you're using "self" to send a message - and you say only that client receives it. Don't you think "self", in this situation, must be the client that triggered the handler?

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export ModuleXNA Export Module
    Fusion 2.5 (Steam)
    Mathias's Avatar
    Join Date
    Jun 2006
    Location
    Copenhagen, Denmark
    Posts
    1,083
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I send a message to every client?

    You'd have to do:

    Code:
    if message.subchannel == 8:
        for connection in self.factory.connections:
            if connection.account is not None:
                connection.sendMessage("Whatever", 8)
    "self" actually refers to the protocol (aka connection) instance. "self.factory" will refer to the factory (aka server), so if you need to share anything between connections, do it through the factory.

    It would probably be an idea to make a factory function ("sendGlobal", perhaps?) that'll send messages to logged in accounts

    Again, you're better off telling us what you're actually trying to achieve

  4. #4
    No Products Registered

    Join Date
    Jan 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I send a message to every client?

    Thanks guys. The code Mathias gave me worked. Just a lack of knowledge of the libraries on my part.

    And for when I ask for help, I generally try to ask as simple a question as I can. I feel that if I provide the whole problem, in the context of my project, that it will be too convoluted to find a good solution, as well as not provide as much help to others. What I provide is generally a distillation of the problem I'm having, after I have narrowed down what it is after hours of debugging.

    Thanks though, everything is working great!

Similar Threads

  1. Is it possible to send an SMS message?
    By kungsangun in forum Android Export Module Version 2.0
    Replies: 0
    Last Post: 31st December 2013, 11:09 AM
  2. Replies: 2
    Last Post: 21st November 2012, 08:47 AM
  3. send file from client to lacewing server
    By Ziyoo in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 7th August 2012, 09:34 PM
  4. How to send alpha-builds to client?
    By BrashMonkey in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 5th December 2011, 02:53 PM
  5. Send a message to yourself?
    By Ryan in forum Lacewing
    Replies: 2
    Last Post: 28th February 2010, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •