SAMP draft document introduction

Mark Taylor m.b.taylor at bristol.ac.uk
Thu May 1 06:53:40 PDT 2008


On Thu, 1 May 2008, Alasdair Allan wrote:

>
> Mark Taylor wrote:
>> that would be great - it would certainly go a long way towards testing 
>> whether there are things we've forgotten to think about or to write down.
>
> The initial thing I've just hit is that when you start up a Hub, it should 
> obviously check to see if one is already running.  It initially looks for a 
> ~/.samp file, but if it finds one it should try to connect to the already 
> running hub to see if its died without cleaning up the lock file. Now, it's a 
> total waste of time to register the new hub, which is probably just about to 
> die again, as a new SAMP client...
>
> So I'm guess (since it doesn't need a client-id) I can just directly call 
> getRegisteredClients() or getHubId() to check that we have a running hub 
> rather than having to register and get a client-id first?

Alasdair,

the method you're after is isAlive().  This is described at point 5
in sec 4.2:

    5. Another new method, isAlive() is added to the hub API.
       This may be called by registered or unregistered applications
       (as a special case the private-key argument may be omitted),
       and can be used to determine whether the hub is responding to requests.
       Any non-error return indicates that the hub is running.

This is profile-dependent, since one could imagine other profiles
in which, for instance, you can always assume that the messaging
subsystem is present.

Although in earlier versions getRegisteredClients() and getHubId()
were callable without having registered, they are not now.  It could
go either way, but I made this rule up on the hoof just so I could
make the Abstract API -> Standard Profile mapping rules as simple
as possible, and write at point 3 in that same list:

    3. All other hub and client methods take the
       private-key as their first argument.

> The specification is vague on this point, so I'm hoping for wiggle room 
> here...?

I hope none is required.

Mark

-- 
Mark Taylor   Astronomical Programmer   Physics, Bristol University, UK
m.b.taylor at bris.ac.uk +44-117-928-8776 http://www.star.bris.ac.uk/~mbt/



More information about the apps-samp mailing list