Home Help Center

How to know the identity name of the server on IceGrid

ferrazrafaelferrazrafael Member Rafael FerrazOrganization: Federal University of Ouro PretoProject: MMOG
Inside the server code, how can I get the server identity?

Exemple: I have 2 servers called "server-${index}" on the template, how can I know if my code is running from "server-1" or "server-2"?

Other thing, I can discover which server or client called the RPC or I need to send with the data Im sending?

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    You can check for the Ice.Admin.ServerId property in the server or set a property within the server descriptor as show in server descriptor element documentation.

    You can obtain connection information on the client or server sending using the Ice::Connection::getInfo() method (you can obtain the connection either through the servant Ice::Current parameter or the proxy ice_getConnection method). If you need other information such as the server identifier, you will need to pass it with the request parameters.

    Cheers,
    Benoit.
  • ferrazrafaelferrazrafael Member Rafael FerrazOrganization: Federal University of Ouro PretoProject: MMOG
    thank you. but there is a way to know which server called a the method on other server?

    Like if a server-1 call another method on server-2, In the server-2 code I can get which server name or id called the method? Or I need to transmit in the message from server-1?

    using current on server-2 I could only get information about the server-2 not the server-1 that invoked the method.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    Ice doesn't provide this information so this is something you will have to provide with the request. You can either provide it explicitly as an extra request parameter or use the request context. See Requests Contexts for more information on contexts.

    Cheers,
    Benoit.
  • ferrazrafaelferrazrafael Member Rafael FerrazOrganization: Federal University of Ouro PretoProject: MMOG
    benoit wrote: »
    Hi,

    Ice doesn't provide this information so this is something you will have to provide with the request. You can either provide it explicitly as an extra request parameter or use the request context. See Requests Contexts for more information on contexts.

    Cheers,
    Benoit.

    thank you, you helped a lot
Sign In or Register to comment.