botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
BotSenseServer.py File Reference

BotSense client - server connection and request functions. More...

Go to the source code of this file.

Functions

def BotSense.BotSenseServer.ServerConnect (client, serverHostName='localhost', serverPort=bsCore.BSPROXY_LISTEN_PORT_DFT)
 Connect to the bsProxy server. More...
 
def BotSense.BotSenseServer.ServerDisconnect (client)
 Disconnect from the bsProxy server. More...
 
def BotSense.BotSenseServer.ServerReqGetVersion (client)
 Proxy server request to get the bsProxy server's version string. More...
 
def BotSense.BotSenseServer.ServerReqLoopback (client, loopbackMsg)
 Proxy server request to loopback the given message. More...
 
def BotSense.BotSenseServer.ServerReqSetLogging (client, level)
 Proxy server request to set the server's diagnostics logging level. More...
 
def BotSense.BotSenseServer.ServerReqMsgTrace (client, hndVConn, trace)
 Proxy server request to enable/disable message tracing on a virtual connection. More...
 
def BotSense.BotSenseServer.ServerReqOpenDev (client, devName, modName, argbuf, appInfo, trace=False)
 Proxy server request to establish a virtual connection to the device end point. More...
 
def BotSense.BotSenseServer.ServerReqCloseDev (client, hndVConn)
 Proxy server request to close a client's virtual connection. More...
 
def BotSense.BotSenseServer.ServerReqGetVConnList (client)
 Proxy server request to retrieve the server's list of virtual connection handles for this client. More...
 
def BotSense.BotSenseServer.ServerReqGetVConnInfo (client, hndVConn)
 Proxy server request to retrieve the servers's information for a given virtual connection. More...
 

Detailed Description

BotSense client - server connection and request functions.

Package
BotSense Python Interface
Module
BotSense .BotSenseServer
File
BotSense/BotSenseServer.py
See also
PyDoc Generated Documentation
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)
License
MIT
EULA
Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that (1) The above copyright notice and the following two paragraphs appear in all copies of the source code and (2) redistributions including binaries reproduces these notices in the supporting documentation. Substantial modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated in all files where they apply.

IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Definition in file BotSenseServer.py.

Function Documentation

def BotSense.BotSenseServer.ServerConnect (   client,
  serverHostName = 'localhost',
  serverPort = bsCore.BSPROXY_LISTEN_PORT_DFT 
)

Connect to the bsProxy server.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
serverHostNameServer's hostname in either a network or a dotted IP address.
serverPortServer's listen port number.

Definition at line 71 of file BotSenseServer.py.

71  serverPort=bsCore.BSPROXY_LISTEN_PORT_DFT):
72  bsTypes.BsClient.ChkClient(client)
73  rc = bsCore.bsServerConnect(client.pClient, serverHostName, serverPort)
74  bsError.ChkReturnIsOk(rc,
75  "Client %s: Failed to connect to bsProxy server at %s:%d." % \
76  (client.AttrGetName(), serverHostName, serverPort))
77 
def BotSense.BotSenseServer.ServerDisconnect (   client)

Disconnect from the bsProxy server.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.

Definition at line 84 of file BotSenseServer.py.

84 def ServerDisconnect(client):
85  bsTypes.BsClient.ChkClient(client)
86  rc = bsCore.bsServerDisconnect(client.pClient)
87  bsError.ChkReturnIsOk(rc,
88  "Client %s: Failed to disconnect from server." % (client.AttrGetName()))
89 
def BotSense.BotSenseServer.ServerReqCloseDev (   client,
  hndVConn 
)

Proxy server request to close a client's virtual connection.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
hndVConnVirtual connection handle to close.

Definition at line 196 of file BotSenseServer.py.

196 def ServerReqCloseDev(client, hndVConn):
197  bsTypes.BsClient.ChkClient(client)
198  rc = bsCore.bsServerReqCloseDev(client.pClient, hndVConn)
199  bsError.ChkReturnIsOk(rc,
200  "Client %s: Server CloseDev request failed." % (client.AttrGetName()))
201 
def BotSense.BotSenseServer.ServerReqGetVConnInfo (   client,
  hndVConn 
)

Proxy server request to retrieve the servers's information for a given virtual connection.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
hndVConnVirtual connection handle.
Returns
Proxied device info.

Definition at line 232 of file BotSenseServer.py.

232 def ServerReqGetVConnInfo(client, hndVConn):
233  bsTypes.BsClient.ChkClient(client)
234  info = bsTypes.BsVConnInfo()
235  rc = bsCore.bsServerReqGetVConnInfo(client.pClient, hndVConn, info)
236  bsError.ChkReturnIsOk(rc,
237  "Client %s: Server GetVConnInfo request failed." % (client.AttrGetName()))
238  return info
239 
def BotSense.BotSenseServer.ServerReqGetVConnList (   client)

Proxy server request to retrieve the server's list of virtual connection handles for this client.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
Returns
List of handles.

Definition at line 211 of file BotSenseServer.py.

211 def ServerReqGetVConnList(client):
212  bsTypes.BsClient.ChkClient(client)
213  vec = bsCore.BsVecHandles_T()
214  rc = bsCore.bsServerReqGetVConnList(client.pClient, vec)
215  bsError.ChkReturnIsOk(rc,
216  "Client %s: Server GetVConnList request failed." % (client.AttrGetName()))
217  listHnds = []
218  for i in xrange(vec.m_uCount):
219  listHnds += [bsCore.hndVConnArray_getitem(vec.m_vecHnd, i)]
220  return listHnds
221 
def BotSense.BotSenseServer.ServerReqGetVersion (   client)

Proxy server request to get the bsProxy server's version string.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
Returns
Version string response.

Definition at line 98 of file BotSenseServer.py.

98 def ServerReqGetVersion(client):
99  verstr = '\x00' * 256
100  rc = bsCore.bsServerReqGetVersion(client.pClient, verstr, len(verstr))
101  bsError.ChkReturnIsOk(rc,
102  "Client %s: Server GetVersion request failed." % (client.AttrGetName()))
103  return verstr.rstrip('\x00')
104 
def BotSense.BotSenseServer.ServerReqLoopback (   client,
  loopbackMsg 
)

Proxy server request to loopback the given message.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
loopbackMsgMessage string to loopback.
Returns
Loopbacked message response.

Definition at line 114 of file BotSenseServer.py.

114 def ServerReqLoopback(client, loopbackMsg):
115  bsTypes.BsClient.ChkClient(client)
116  txrxMsg = loopbackMsg
117  rc = bsCore.bsServerReqLoopback(client.pClient, txrxMsg)
118  bsError.ChkReturnIsOk(rc,
119  "Client %s: Server Loopback request failed." % (client.AttrGetName()))
120  return txrxMsg
121 
def BotSense.BotSenseServer.ServerReqMsgTrace (   client,
  hndVConn,
  trace 
)

Proxy server request to enable/disable message tracing on a virtual connection.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
hndVConnVirtual connection handle.
traceEnable(true) or disable(false) message tracing.

Definition at line 144 of file BotSenseServer.py.

144 def ServerReqMsgTrace(client, hndVConn, trace):
145  bsTypes.BsClient.ChkClient(client)
146  if trace:
147  trace = True
148  else:
149  trace = False
150  rc = bsCore.bsServerReqMsgTrace(client.pClient, hndVConn, trace)
151  bsError.ChkReturnIsOk(rc,
152  "Client %s: Server MsgTrace request failed." % (client.AttrGetName()))
153 
def BotSense.BotSenseServer.ServerReqOpenDev (   client,
  devName,
  modName,
  argbuf,
  appInfo,
  trace = False 
)

Proxy server request to establish a virtual connection to the device end point.

The device is open if not already opened by another virtual connection. Otherwise it is attached to this vconn.

The interface module is dynamically loaded into the server and provides the set of services for the client application communicating with the device.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
devNameDevice path name string.
modNameInterface module path name string.
argbufPacked buffer of module-specific open parameters.
appInfoApplication-specific information and callbacks (optional). Set to None if no info. Set any member to None to ignore that value.
traceInitial message tracing enable(true)/disable(false) state.
Returns
New virtual connection handle.

Definition at line 177 of file BotSenseServer.py.

177 def ServerReqOpenDev(client, devName, modName, argbuf, appInfo, trace=False):
178  bsTypes.BsClient.ChkClient(client)
179  if appInfo is not None:
180  bsError.ChkType(appInfo, bsTypes.BsClientAppInfo)
181  argByteBuf = bsTypes.ByteBuf.Clone(argbuf)
182  argByteBuf.copyToSwigObj(len(argByteBuf))
183  hndVConn = bsCore.bsServerReqOpenDev(client.pClient, devName, modName,
184  argByteBuf.getSwigObj(), len(argByteBuf), appInfo, trace)
185  bsError.ChkReturnIsNonNeg(hndVConn,
186  "Client %s: Server OpenDev request failed." % (client.AttrGetName()))
187  return hndVConn
188 
def BotSense.BotSenseServer.ServerReqSetLogging (   client,
  level 
)

Proxy server request to set the server's diagnostics logging level.

Raises a BotSenseError exception on failure.

Parameters
clientBotSenseTypes.BsClient instance.
levelLog level.

Definition at line 129 of file BotSenseServer.py.

129 def ServerReqSetLogging(client, level):
130  bsTypes.BsClient.ChkClient(client)
131  rc = bsCore.bsServerReqSetLogging(client.pClient, level)
132  bsError.ChkReturnIsOk(rc,
133  "Client %s: Server SetLogging request failed." % (client.AttrGetName()))
134