Dear Alex,
here the code : 

class TestServer1(rpyc.Service):
    def on_connect(self):
        # code that runs when a connection is created
        # (to init the serivce, if needed)
        s_ConnectionID=self._conn._config['connid']
        s_Credentials=self._conn._config['credentials']
        s_HostAdress, s_HostPort=self._conn._config['endpoints'][0]
        s_ClientAdress, s_ClientPort=self._conn._config['endpoints'][1]
        print('Connection created - ID: {ConnectionID}, Credentials: 
{Credentials}, Server: {HostAdress}:{HostPort}, Client : 
{ClientAdress}:{ClientPort}'.format(ConnectionID=s_ConnectionID,Credentials=s_Credentials,HostAdress=s_HostAdress,HostPort=s_HostPort,ClientAdress=s_ClientAdress,ClientPort=s_ClientPort))
        pass

    def on_disconnect(self):
        # code that runs when the connection has already closed
        # (to finalize the service, if needed)
        s_ConnectionID=self._conn._config['connid']
        s_Credentials=self._conn._config['credentials']
        s_HostAdress, s_HostPort=self._conn._config['endpoints'][0]
        s_ClientAdress, s_ClientPort=self._conn._config['endpoints'][1]
        print('Connection closed - ID: {ConnectionID}, Credentials: 
{Credentials}, Server: {HostAdress}:{HostPort}, Client : 
{ClientAdress}:{ClientPort}'.format(ConnectionID=s_ConnectionID,Credentials=s_Credentials,HostAdress=s_HostAdress,HostPort=s_HostPort,ClientAdress=s_ClientAdress,ClientPort=s_ClientPort))
        pass

    def exposed_TestRequest(self,s_Message,n_wait): # this is an exposed 
method
        s_ConnectionID=self._conn._config['connid']
        s_Credentials=self._conn._config['credentials']
        s_HostAdress, s_HostPort=self._conn._config['endpoints'][0]
        s_ClientAdress, s_ClientPort=self._conn._config['endpoints'][1]
        print('Server Request - ID: {ConnectionID}, Credentials: 
{Credentials}, Server: {HostAdress}:{HostPort}, Client : 
{ClientAdress}:{ClientPort}'.format(ConnectionID=s_ConnectionID,Credentials=s_Credentials,HostAdress=s_HostAdress,HostPort=s_HostPort,ClientAdress=s_ClientAdress,ClientPort=s_ClientPort))
        print('                 Nachricht : {Message}, warte {WaitingTime} 
Sekunden'.format(WaitingTime=n_wait,Message=s_Message))
        time.sleep(n_wait)
        return 42 # the answer to all questions

yours sincerely

Robert

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"rpyc" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to