Simple Network Event Server

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
andersh
Posts: 6
Joined: Tue May 15, 2018 5:15 am

Simple Network Event Server

Post by andersh » Wed May 16, 2018 10:18 am

I've recently moved from Girder to Eventghost.
In Girder I was using their "Simple Transport Plugin" to send data to a python script. This plugin is really just dumping the payload raw to a TCP socket, so I was able to handle it with an extremely simple script like this:

Code: Select all

import socket
import sys
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('10.0.0.10', 10000)
sock.bind(server_address)
sock.listen(1)
while True:
    connection, client_address = sock.accept()
    try:
        while True:
            data = connection.recv(16)
            if data:
# do something with data
            else:
                print >>sys.stderr, 'no more data from', client_address
                break          
    finally:
        connection.close()
I see that the "Network Event Server" adds a little more protocol in order to function. Is there a python example somewhere that sketches out something similar to the above using "Network Event"? I'd need to run this as a background process on an Android device (which is how I'm already handling the existing solution) I'm not really a programmer so something a bit elaborate would be appreciated...

User avatar
topix
Experienced User
Posts: 415
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Simple Network Event Server

Post by topix » Mon May 21, 2018 11:12 am

I'm not sure if i understand it correct: You want to send some data from EventGhost to your android device which is running the python script?

andersh
Posts: 6
Joined: Tue May 15, 2018 5:15 am

Re: Simple Network Event Server

Post by andersh » Wed May 23, 2018 8:45 am

Yes.
The python script is running on the Android side, receiving data from Eventghost and (among other things) simulating keypresses on the Android device.
This is working fine today with Girder, but I see that I need to add some more protocol handling to it in order to work as a server for the Network Event Client.

User avatar
kgschlosser
Site Admin
Posts: 4206
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Simple Network Event Server

Post by kgschlosser » Fri May 25, 2018 4:28 am

the network event send/receiver plugins have a set of keywords to dictate what is going on. this allows for use of a password and that password along with some salt is turned into a cookie. i do not know what level your programming skills are and if it is something you would be able to replicate on the android device.


i am not sure if making it work with the existing network sender/receiver plugins would be easier to or if making a version of the network sender/receiver plugins to work with your setup would be easier.


I am thinking that altering the send and receive plugins to work might be easier. give me a few days and let me get something together for ya.
If you like the work I have been doing then feel free to Image

andersh
Posts: 6
Joined: Tue May 15, 2018 5:15 am

Re: Simple Network Event Server

Post by andersh » Fri May 25, 2018 5:28 am

My coding skills are somewhat rudimentary. I did already write the existing script, but that's probably stretching it to my limits. :-)

Any help with this would be appreciated - thanks a lot for the offer. Having a send plugin that just dumps a payload to my script would work fine.

User avatar
kgschlosser
Site Admin
Posts: 4206
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Simple Network Event Server

Post by kgschlosser » Sat May 26, 2018 1:18 pm

here you go sir. i hope this takes care of your problem.
Attachments
RawTCP-0.1.0b.egplugin
(2.62 KiB) Downloaded 26 times
If you like the work I have been doing then feel free to Image

andersh
Posts: 6
Joined: Tue May 15, 2018 5:15 am

Re: Simple Network Event Server

Post by andersh » Sun May 27, 2018 8:31 pm

Thanks a lot, that looks like it should do the trick. I did a very quick test, but unfortunately ran into a problem:

Error starting plugin: Raw TCP
Traceback (most recent call last) (0.5.0-rc4):
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 223, in Stop
self.instance.__stop__()
File "C:\Program Files (x86)\EventGhost\plugins\RawTCP\__init__.py", line 100, in __stop__
self.socket_handler.stop()
File "C:\Program Files (x86)\EventGhost\plugins\RawTCP\__init__.py", line 75, in stop
self.sock.close()
AttributeError: 'NoneType' object has no attribute 'close'

User avatar
kgschlosser
Site Admin
Posts: 4206
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Simple Network Event Server

Post by kgschlosser » Sun May 27, 2018 10:04 pm

no worries easy fix.
Attachments
RawTCP-0.0.2b.egplugin
(2.64 KiB) Downloaded 26 times
If you like the work I have been doing then feel free to Image

andersh
Posts: 6
Joined: Tue May 15, 2018 5:15 am

Re: Simple Network Event Server

Post by andersh » Mon May 28, 2018 6:23 pm

kgschlosser wrote:
Sun May 27, 2018 10:04 pm
no worries easy fix.
That seems to have done the trick. At least my first test was successful. Thanks a lot.

User avatar
kgschlosser
Site Admin
Posts: 4206
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Simple Network Event Server

Post by kgschlosser » Mon May 28, 2018 7:51 pm

hey no worries.

It is working yes???
If you like the work I have been doing then feel free to Image

andersh
Posts: 6
Joined: Tue May 15, 2018 5:15 am

Re: Simple Network Event Server

Post by andersh » Tue May 29, 2018 6:08 am

I've done some more testing, and can confirm that this is working just fine in my setup.

User avatar
kgschlosser
Site Admin
Posts: 4206
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Simple Network Event Server

Post by kgschlosser » Tue May 29, 2018 7:29 am

good deal. glad you came on over to EventGhost. If there is anything else please don't hesitate to ask.
If you like the work I have been doing then feel free to Image

Post Reply