Skip to main content
Participant
January 9, 2022
Question

How to use broadcastMsg to communicate with my AMS application?

  • January 9, 2022
  • 1 reply
  • 772 views

Hello,

 

I'm trying to communicate with my AMS application through the Administration API, using the broadcastMsg() method.
If I understood the documentation correctly, it should be able to call a function I have in my main.asc file. I think I misunderstand, because I try to call the addActorIP function, but nothing happens.

Can you please help me?

 

Here is my request: http://MY_SERVER_IP:1111/admin/broadcastMsg?auser=MY_USERNAME&apswd=MY_PASSWORD&scope="App:myApp/_definst_"&method="addActorIP"&arg0="1"&arg1="127.0.0.1"

 

Here is my server side code:

 

var clients = {};
var games = {};

application.allowDebug = true;

application.onAppStart = function () {
    trace("[System] FMS server started.");
}

application.onConnect = function (client, actorid) {
    trace("[Login] ActorId: " + actorid);
    client.ActorId = actorid;
    clients[actorid] = client;
    application.acceptConnection(client);

    // trace(client.ip);

    var so = SharedObject.get("CONNECT-actorId-" + actorid, true);
    so.setProperty("connectStatus", actorid + ":connected");

    client.addActorIP = function(ActorId, IP) {
        // var user = SharedObject.get("IP-" + ActorId + "-" + IP);

        trace("ActorId: " + ActorId + ", IP: " + IP);
    }

    application.onDisconnect = function (client) {
        // code here
        }
    }

    application.onAppStop = function () {
        trace("[System] Clearing shared objects...");
        application.clearSharedObjects("/");
        application.shutdown();
    }
}

 

Good evening, and thank you in advance for your answers!

~ Polo

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    March 30, 2023

    It looks like you are trying to use the addActorIP function in your AMS application via the administration API. You may not have set up your application correctly to accept such calls via the API.