#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <pthread.h>
#include <ctype.h>
#include "samp.h"
Defines | |
#define | HUB_DBG (getenv("HUB_DBG")!=NULL||access("/tmp/HUB_DBG",F_OK)==0) |
Functions | |
handle_t | samp_hubOpen (Samp *sampP) |
Discover and open a connection to the SAMP Hub. | |
int | samp_hubClose (handle_t handle) |
Close a connection to the Hub. | |
int | samp_hubRunning (void) |
List | samp_getAvailableHubs (handle_t handle) |
Get a list of available Hubs. | |
char * | samp_getActiveHubName (handle_t handle) |
int | samp_getActiveHub (handle_t handle) |
int | samp_hubInit (handle_t handle, char *appName, char *descr) |
int | samp_processHubEvent (String mtype, Map params) |
Determine the type of Hub event mtype. | |
int | samp_hubEvent (String mtype) |
Determine the type of Hub event mtype. | |
int | samp_hubRegister (Hub *hub) |
Send a Register message to the Hub. | |
int | samp_hubUnRegister (Hub *hub) |
Send a UnRegister message to the Hub. | |
int | samp_hubSendShutdown (Hub *hub) |
Send a samp.app.event.shutdown message to the Hub. | |
int | samp_hubSetXmlrpcCallback (Hub *hub) |
Set the client callback and send to Hub. | |
int | samp_hubPing (Hub *hub) |
Ping the Hub to see if it is alive. | |
int | samp_hubDeclareMetadata (Hub *hub) |
Declare "standard" metadata to the Hub. | |
int | samp_hubDeclareSubscriptions (Hub *hub) |
Declare mtype subscriptions to the Hub. | |
Variables | |
Hub * | hub = (Hub *) NULL |
int | numHubs = 0 |
handle_t | hubHandles [MAX_HUBS] |
pthread_mutex_t | samp_mutex = PTHREAD_MUTEX_INITIALIZER |
Samp * | sampP |
int | numSamps |
handle_t | sampHandles [MAX_SAMPS] |
Map | nullMap |
SAMPHUB.C -- Methods related to the SAMP Hub interface.
List samp_getAvailableHubs | ( | handle_t | handle | ) |
Get a list of available Hubs.
SAMP_GETAVAILABLEHUBS -- Get a list of available Hubs
handle | hub handle |
int samp_hubClose | ( | handle_t | handle | ) |
Close a connection to the Hub.
SAMP_HUBCLOSE -- Close a connection to the Hub.
handle | hub handle |
References appMD::aKey, appMD::aVal, Hub::meta, appMD::nkeys, samp_freeHandle(), and samp_hubUnRegister().
Referenced by sampClose(), and sampShutdown().
int samp_hubDeclareMetadata | ( | Hub * | hub | ) |
Declare "standard" metadata to the Hub.
SAMP_DECLAREMETADATA -- Declare "standard" metadata to the Hub.
hub | hub struct pointer |
References appMD::aKey, appMD::aVal, Hub::description, appMD::docURL, appMD::iconURL, Hub::id, Hub::meta, appMD::nkeys, and Hub::privateKey.
Referenced by samp_DeclareMetadata(), and sampStartup().
int samp_hubDeclareSubscriptions | ( | Hub * | hub | ) |
Declare mtype subscriptions to the Hub.
SAMP_HUBDECLARESUBSCRIPTIONS -- Declare mtype subscriptions to the Hub.
hub | hub struct pointer |
References Hub::id, Samp::nsubs, nullMap, Hub::privateKey, Hub::samp, samp_freeMap(), and Subs::userFunc.
Referenced by samp_DeclareSubscriptions(), and sampStartup().
int samp_hubEvent | ( | String | mtype | ) |
Determine the type of Hub event mtype.
SAMP_HUBEVENT -- Determine the type of Hub event mtype.
mtype | mtype string |
References HUB_SHUTDOWN.
Referenced by samp_processHubEvent().
handle_t samp_hubOpen | ( | Samp * | sampP | ) |
Discover and open a connection to the SAMP Hub.
SAMP_HUBOPEN -- Discover and open a connection to the SAMP Hub.
samp | Same structure |
References Hub::appId, Samp::appVer, Hub::appVer, appMD::desc, Hub::description, Samp::description, Hub::id, Hub::meta, Hub::samp, samp_hubRegister(), samp_hubSetXmlrpcCallback(), samp_newHandle(), samp_P2H(), Hub::timeout, and Hub::url.
Referenced by sampInit(), and sampStartup().
int samp_hubPing | ( | Hub * | hub | ) |
Ping the Hub to see if it is alive.
SAMP_HUBPING -- Ping the Hub to see if it is alive.
hub | hub struct pointer |
References Hub::id, and Hub::privateKey.
Referenced by samp_Ping().
int samp_hubRegister | ( | Hub * | hub | ) |
Send a Register message to the Hub.
SAMP_HUB_REGISTER -- Send a Register message to the Hub.
hub | hub struct pointer |
References Hub::hubId, Hub::id, Hub::privateKey, Hub::secret, and Hub::selfId.
Referenced by samp_hubOpen().
int samp_hubRunning | ( | void | ) |
int samp_hubSendShutdown | ( | Hub * | hub | ) |
Send a samp.app.event.shutdown message to the Hub.
SAMP_HUBSENDSHUTDOWN -- Send a samp.app.event.shutdown message to the Hub.
hub | hub struct pointer |
References Hub::id, Hub::privateKey, and samp_nullResponse().
int samp_hubSetXmlrpcCallback | ( | Hub * | hub | ) |
Set the client callback and send to Hub.
SAMP_HUBSETXMLRPCCALLBACK -- Set the client callback and send to Hub
hub | hub struct pointer |
References Hub::id, Hub::privateKey, and samp_serverPort().
Referenced by samp_hubOpen().
int samp_hubUnRegister | ( | Hub * | hub | ) |
Send a UnRegister message to the Hub.
SAMP_HUBUNREGISTER -- Send a UnRegister message to the Hub.
hub | hub struct pointer |
References Hub::id, and Hub::privateKey.
Referenced by samp_hubClose(), and samp_UnRegister().
Determine the type of Hub event mtype.
SAMP_HUBEVENT -- Determine the type of Hub event mtype.
mtype | mtype string | |
params | message parameter Map |
References HUB_SHUTDOWN, samp_addClient(), samp_hubEvent(), samp_mutex, samp_P2H(), samp_removeClient(), sampH, and sampShutdown().
Referenced by samp_receiveNotification().
empty List struct
Referenced by samp_bibLoad(), samp_call(), samp_callAll(), samp_callAndWait(), samp_cmdExec(), samp_coordPointAtSky(), samp_DeclareMetadata(), samp_DeclareSubscriptions(), samp_envGet(), samp_envSet(), samp_GetMetadata(), samp_imageLoadFITS(), samp_notify(), samp_notifyAll(), samp_paramGet(), samp_paramSet(), samp_Register(), samp_Reply(), samp_resourceLoad(), samp_sendGeneric(), samp_specLoadSSAGeneric(), samp_tableHighlightRow(), samp_tableLoadFITS(), samp_tableLoadVOTable(), samp_tableSelectRowList(), and samp_UnRegister().
handle_t hubHandles[MAX_HUBS] |
No. of available hubs
int numHubs = 0 |
HUB connection
pthread_mutex_t samp_mutex = PTHREAD_MUTEX_INITIALIZER |
lock so we can update struct
Referenced by samp_processHubEvent().