def __init__(self, sck, address = None, handler_factory = None): self._debug_socket = False self._debug_dispatch = False self._buffer = b'' self._sck = sck self._address = address self._handler = handler_factory self.connection_status = "open" if self._handler: self.handler = self._handler(self) self._id = 0 self._requests = {} self._objects = {} self.scklock = threading.Lock() self.call = Proxy(self, sync_type=0) self.method = Proxy(self, sync_type=1) self.notify = Proxy(self, sync_type=2) self.pipe = Proxy(self, sync_type=3) self._wbuffer = b'' self.write_lock = threading.RLock() self.read_lock = threading.RLock() self.getid_lock = threading.Lock() self.reading_event = threading.Event() self.threaded = bjsonrpc_options['threaded'] self.write_thread_queue = [] self.write_thread_semaphore = threading.Semaphore(0) self.write_thread = threading.Thread(target=self.write_thread) self.write_thread.daemon = True self.write_thread.start()
def __init__(self, conn, obj): self._conn = conn self.name = obj['__remoteobject__'] self.call = Proxy(self._conn, obj=self.name, sync_type=0) self.method = Proxy(self._conn, obj=self.name, sync_type=1) self.notify = Proxy(self._conn, obj=self.name, sync_type=2) self.pipe = Proxy(self._conn, obj=self.name, sync_type=3)
def __init__(self, conn, obj): self._conn = conn self.name = obj['__remoteobject__'] self.call = Proxy(self._conn, obj=self.name, sync_type=0) self.method = Proxy(self._conn, obj=self.name, sync_type=1) self.notify = Proxy(self._conn, obj=self.name, sync_type=2)
class RemoteObject(object): """ Represents a object in the server-side (or client-side when speaking from the point of view of the server) . It remembers its name in the server-side to allow calls to the original object. Parameters: **conn** Connection object which holds the socket to the other end of the communications **obj** JSON object (Python dictionary) holding the values recieved. It is used to retrieve the properties to create the remote object. (Initially only used to get object name) Example:: list = conn.call.newList() for i in range(10): list.notify.add(i) print list.call.getitems() Attributes: **name** name of the object in the server-side **call** Synchronous Proxy. It forwards your calls to it to the other end, waits the response and returns the value. **method** Asynchronous Proxy. It forwards your calls to it to the other end and inmediatelly returns a *request.Request* instance. **pipe** Asynchronous Proxy for "pipe" calls with multiple returns, like method but you can check request.value multiple times, and must call request.close() when you're done. **notify** Notification Proxy. It forwards your calls to it to the other end and tells the server to not response even if there's any error in the call. Returns *None*. """ name = None call = None method = None notify = None pipe = None @property def connection(self): """ Public property to get the internal connection object. """ return self._conn def __init__(self, conn, obj): self._conn = conn self.name = obj["__remoteobject__"] self.call = Proxy(self._conn, obj=self.name, sync_type=0) self.method = Proxy(self._conn, obj=self.name, sync_type=1) self.notify = Proxy(self._conn, obj=self.name, sync_type=2) self.pipe = Proxy(self._conn, obj=self.name, sync_type=3) def __del__(self): self._close() def _close(self): """ Internal close method called both by __del__() and public method close() """ self.call.__delete__() self.name = None def close(self): """ Closes/deletes the remote object. The server may or may not delete it at this time, but after this call we don't longer have any access to it. This method is automatically called when Python deletes this instance. """ return self._close()
class RemoteObject(object): """ Represents a object in the server-side (or client-side when speaking from the point of view of the server) . It remembers its name in the server-side to allow calls to the original object. Parameters: **conn** Connection object which holds the socket to the other end of the communications **obj** JSON object (Python dictionary) holding the values recieved. It is used to retrieve the properties to create the remote object. (Initially only used to get object name) Example:: list = conn.call.newList() for i in range(10): list.notify.add(i) print list.call.getitems() Attributes: **name** name of the object in the server-side **call** Synchronous Proxy. It forwards your calls to it to the other end, waits the response and returns the value. **method** Asynchronous Proxy. It forwards your calls to it to the other end and inmediatelly returns a *request.Request* instance. **pipe** Asynchronous Proxy for "pipe" calls with multiple returns, like method but you can check request.value multiple times, and must call request.close() when you're done. **notify** Notification Proxy. It forwards your calls to it to the other end and tells the server to not response even if there's any error in the call. Returns *None*. """ name = None call = None method = None notify = None pipe = None @property def connection(self): """ Public property to get the internal connection object. """ return self._conn def __init__(self, conn, obj): self._conn = conn self.name = obj['__remoteobject__'] self.call = Proxy(self._conn, obj=self.name, sync_type=0) self.method = Proxy(self._conn, obj=self.name, sync_type=1) self.notify = Proxy(self._conn, obj=self.name, sync_type=2) self.pipe = Proxy(self._conn, obj=self.name, sync_type=3) def __del__(self): self._close() def _close(self): """ Internal close method called both by __del__() and public method close() """ self.call.__delete__() self.name = None def close(self): """ Closes/deletes the remote object. The server may or may not delete it at this time, but after this call we don't longer have any access to it. This method is automatically called when Python deletes this instance. """ return self._close()