TCPEvents : A better Network Event Receiver/Sender plugin

Questions and comments specific to a particular plugin should go here.

TCPEvents : A better Network Event Receiver/Sender plugin

Postby miljbee » Fri Dec 10, 2010 1:08 pm

Image
Edit 03 Feb 2013:
- Added the mandatory guid for the plugin (sorry !)
- Updated a few comments on the demo tree
- Serious work started on the corresponding C# client/server

Edit 02 Feb 2013:
Updated the demo tree to show the compatibility with the good old Network event Receiver/Sender Plugins

Edit 01 Feb 2013:
Updated and tested with the latest 2013 EG release ( and yes pako, it runs with the -translate switch ...).
It's in my "prod" tree and runs smoothly without any bugs since several months.
I have added a demo tree so you can quickly check and understand what it can do.

Edit 06 Jan 2010 :
Better Exception Handling

Edit 17 Dec 2010 :
BugFix : added a try/except arround the eval of the received payload in the server

Edit 16 Dec 2010 :
Improvement : added datetime module to the plugin to enable the exchange of datetime objects

Edit 13 Dec 2010 :
BugFix : RequestData/unable to read the response from the server if it sends close behind the response


Hello,

I find that the actual network event receiver/sender plugins are quiet limited.

So I wrote a new one.
The key features are :
    This is a single plugin to send AND receive
      You specify the destination host in the action (not in the plugin)
    It is fully compatible with the originals network event sender/receiver plugins:
      You can send an event from this plugin and receive it with the network event receiver
      You can send an event with the network event sender and receive it with this new plugin
    You can choose the event prefix when sending
    You can send/receive payload of any type (at least simple ones : strings, numbers, lists, dicts, tuples, datetime ...)
    You can Send data without generating an event at the server side
    You can Send a python expression and the server will evaluate it and return the result without generating any event

Status of the plugin :
    Please, consider it as beta, since I still don't use it in my "prod" tree.
    I wrote that plugin to be able to have a "rich" dialog between two of my computers, but also to exchange data with external programs written in C#. So you can expect me to re-write it in C# in "some" time. Once the C# part will be completed, I will integrate this into my "prod" tree.

Known Bug :
    I have written the plugin based on the network event sender/receiver code. Unfortunately, there is a bug in the original plugins. And I haven't manage to solve it in my plugin.
    The bug occurs when the plugin is loaded and you restart eventghost.
    when you restart eventghost, there might be a 30s delay before the server might be able to receive data.
    I haven't been able to determine if it's a problem with closing properly the socket when exiting eventghost, or if it's when creating it when eg starts (Perhaps something with restartasynchcore).
    Anyway, if you haven't noticed this bug with the original network event receiver plugin, you shouldn't notice it with this one.
    If you have any idea about how to solve it, let me know.

Things you might want to know/understand
    when sending an event, you can use {} in most params to have eg replace the content by the corresponding vars in eg.globals :
      as an exemple, if you have 'test' in eg.globals.myVar, you can write {eg.globals.myVar} in the event suffix field. It will send 'test' as the event suffix to the server. It works with these fields :
      Hostname
      password
      event Prefix
      event Suffix
    when sending the payload with an event, you should write a python expression in the payload field. If you want to send just a plain text string, you should write it between quotes (or double quotes) :
    Code: Select all
    'my text'

    This enables you to send much more complex data. exemple :
    Code: Select all
    [1,"two",{3:"three"},eg.globals.myVar]

    The content of the payload field is always evaluated before being sent, so any variable will be replaced by its value

    when sending data, you should also write a python expression which will be evaluated before being sent (same thing as the event payload).
    when sending data, the server won't produce any event. It will only store it with the provided name.
    To get back the data at the server side, use the action "Retrieve Received Data". It will store the data in eg.result.
      or just use eg.plugins.TCPEvents.GetData(u'data1') in your python scripts

    When Requesting data to a remote host, you write a plain python expression. exemple : eg.globals.myVar. The string you write here is sent to the server which will evaluate it and will return to the client the result of the evaluated expression. You get that result by reading eg.result.

I Hope you will like it. Let me know what you think of it.

regards,
Image
Attachments
__init__.py
(31.58 KiB) Downloaded 74 times
TCPEventsDemo.xml
(6.7 KiB) Downloaded 65 times
Last edited by miljbee on Sun Feb 03, 2013 10:43 am, edited 3 times in total.
miljbee
Experienced User
 
Posts: 137
Joined: Fri Mar 27, 2009 1:29 pm

Re: TCPEvents : A better Network Event Receiver/Sender plugi

Postby Pako » Sat Feb 02, 2013 8:57 am

miljbee wrote:Updated and tested with the latest 2013 EG release ( and yes pako, it runs with the -translate switch)
:D

Thank you - it looks like EventGhost will turn a little better.
I'll also definitely try it.

Pako
User avatar
Pako
Plugin Developer
 
Posts: 1283
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic


Return to Plugin Support

Who is online

Users browsing this forum: No registered users and 2 guests