Date:  11/20/2014 05:16:55 PM Msg ID:  004744
From:  Steve Moore Thread:  004742
Subject:  Re: Show_channels
Thanks a million, Ill give this a look!
Sent by FoxWeb Support on 11/20/2014 12:50:41 PM:
FoxWeb uses network sockets for communications between its various components, so it would be hard to duplicate the code that show_channels uses. However, you can get close just be checking the values of semaphores. Here's some code you can use inside a VFP program. The usual disclaimers apply. This code has not been tested thoroughly and is not supported:
 

#DEFINE SEMAPHORE_ALL_ACCESS 2031619

DECLARE INTEGER OpenSemaphore IN WIN32API INTEGER, INTEGER, STRING

DECLARE INTEGER CloseHandle IN WIN32API INTEGER

DECLARE INTEGER WaitForSingleObject IN WIN32API INTEGER, INTEGER

DECLARE INTEGER ReleaseSemaphore IN WIN32API INTEGER, INTEGER, INTEGER

DECLARE INTEGER GetLastError IN WIN32API

LOCAL count, FW_S1, RetVal, TotalChannels, channels, TimeExtension, ChannelStatus

 

CLEAR

TotalChannels = VAL(RegGet('TotalChannels'))

FOR count = 1 TO TotalChannels

M.FW_S1 = OpenSemaphore(SEMAPHORE_ALL_ACCESS, 0, 'S1FW'+LTRIM(STR(M.Count)))

IF M.FW_S1 = 0

M.FW_S1 = OpenSemaphore(SEMAPHORE_ALL_ACCESS, 0, 'Global\S1FW'+LTRIM(STR(M.Count)))

ENDIF

IF M.FW_S1 != 0

RetVal = WaitForSingleObject(M.FW_S1, 0)

IF M.RetVal = 0

ReleaseSemaphore(M.FW_S1, 1, 0)

ChannelStatus = "Ready"

ELSE

ChannelStatus = "Busy"

ENDIF

CloseHandle(M.FW_S1)

ELSE

ChannelStatus = "Unreachable"

ENDIF

? "Channel " + LTRIM(STR(M.Count)) + ": " + ChannelStatus

NEXT

RETURN

 

 

FUNCTION regget

PARAMETERS Name, key, CurrentUser

 

*********************************************

#DEFINE REG_PATH 'SOFTWARE\Aegis Group\FoxWeb\CurrentVersion'

#DEFINE HKEY_CURRENT_USER 0x80000001

#DEFINE HKEY_LOCAL_MACHINE 0x80000002

* -- Key Data Types

#DEFINE REG_SZ         1   && string

#DEFINE REG_EXPAND_SZ  2

#DEFINE REG_BINARY     3   && binary

#DEFINE REG_DWORD      4   && 32-bit number

 

*Windows API declarations

DECLARE Integer RegOpenKey IN Win32API Integer, String@, Integer@

DECLARE Integer RegCloseKey IN Win32API Integer nHKey

DECLARE Integer RegQueryValueEx IN Win32API Integer, String, ;

  Integer, Integer@, String@, Integer@

 

PRIVATE KeyHandle, Data, DataLen, path

IF PARAMETERS() > 1 .AND. TYPE('M.key') = 'C'

IF LEFT(M.key,1) = '\'

M.Path = SUBSTR(M.key,2)

ELSE

M.Path = REG_PATH+'\'+M.key

ENDIF

ELSE

M.Path = REG_PATH

ENDIF

KeyHandle=0

Data = SPACE(256)

DataLen = LEN(M.Data)

Type = 0

IF M.CurrentUser

= RegOpenKey(HKEY_CURRENT_USER, M.Path, @M.KeyHandle)

ELSE

= RegOpenKey(HKEY_LOCAL_MACHINE, M.Path, @M.KeyHandle)

ENDIF

= RegQueryValueEx(M.KeyHandle, M.Name, 0, @M.type, @M.Data, @M.DataLen)

= RegCloseKey(M.KeyHandle)

 

IF M.DataLen < AT(CHR(0), M.Data)-1

RETURN LEFT(M.Data, M.DataLen)

ELSE

RETURN LEFT(M.Data, AT(CHR(0), M.Data)-1)

ENDIF

ENDFUNC 


 
FoxWeb Support Team
support@foxweb.com email
 
Sent by Steve Moore on 11/20/2014 04:53:27 AM:
Is there source available for show_channels.fwx? How can I programattically tell what channels are dead or disappeared? I need to code my own version of show_channels so I can send alerts upon certain conditions such as a channel that has not restarted correctly.