Remote Control Version 1.0.0 (Sep 07, 2011)
Matthieu Casanova <chocolat.mou@gmail.com> 
Introduction

This plugin is a remote control for jEdit. It is used to open a remote api to control jEdit over the network. To be useful you will need an external application that will be the client.

Protocol description

Introduction

The network protocol works over TCP, the default port is 53348. The data are text encoded in UTF-8.
Using that protocol you will be able to send commands to jEdit (beanshell, invoke actions), receive the result of your commands, and listen for EBMessage from EditBus.
The protocol is asynchronous, this mean that you can receive messages at any time, and that when you invoke actions the action result will not be returned immediately (it is quick but you could receive other events between your request and the response).

Before being able to send and receive messages, you have to identify you. It is the handshake, that is described next

Handshake

To start a connection the plugin can have different options : challenge, handshake or nothing. Challenge have a little security to ensure that anyone will not connect to your jEdit, handshake is only a welcome message and nothing is no security at all. By default RemoteControl will ask for a challenge. This is to ensure a minimal security.

Challenge

The default mode. It uses a pincode that must be the same on jEdit and on your client. That code is never sent on the network and must be entered as a setting of your program and of the RemoteControl plugin. By default this pincode is 1234

When you connect, you have to send jEdit-RemoteServer-Hello\n
Immediately you will receive jEdit-RemoteServer-Welcome-Challenge-xxxx where xxxx is a random text. With that text you have to calculate the md5 of pincode+jEdit-RemoteServer-Welcome-Challenge-xxxx for example md5(1234jEdit-RemoteServer-Welcome-Challenge-xxxx).
then you return jEdit-RemoteServer-Challenge-Answer-yyyyy where yyyyy is the md5 hash you just calculated. If your hash is good, you will receive jEdit-RemoteServer-Welcome, otherwise the connection will be closed

   client                                   RemoteControlPlugin
      |                                               |
      |           jEdit-RemoteServer-Hello            |
      |---------------------------------------------->|
      |   jEdit-RemoteServer-Welcome-Challenge-xxxx   |
      |<----------------------------------------------|
      |   jEdit-RemoteServer-Challenge-Answer-yyyyy   |
      |---------------------------------------------->|
      |           jEdit-RemoteServer-Welcome          |
      |<----------------------------------------------|

Handshake

   client                                   RemoteControlPlugin
      |                                               |
      |           jEdit-RemoteServer-Hello            |
      |---------------------------------------------->|
      |           jEdit-RemoteServer-Welcome          |
      |<----------------------------------------------|

Invoke an action

To invoke an action just send
A:actionname
ex:
A:next-buffer
Invoking an action do not return anything and you don't know when it is invoked (it is quick but not immediate)

Invoke random code

To invoke a random code send (carreful the 3 : are important)
S:[transactionId]:[engine]:beanshell
The transactionId is an optional String. If you don't provide one, it means you don't want the result of your code. Otherwise you can send any text you like (it is not interpreted by the plugin, and you will get a result that will contains your transactionId and the result of your command.
The engine is also optional, at this time the only allowed value is bsh, or empty value (both are calling the beanshell engine. S:::beanshell
ex:
S:::jEdit.newView(null);
If you want to get the result of that command you have.

Registering and unregistering EBMessages

To receive EBMessage you have to register as a listener for them.
Register a message
R:org.gjt.sp.jedit.msg.ViewUpdate or
R:org.gjt.sp.jedit.msg.ViewUpdate,org.gjt.sp.jedit.msg.BufferUpdate
Unregister a message
U:org.gjt.sp.jedit.msg.ViewUpdate or
U:org.gjt.sp.jedit.msg.ViewUpdate,org.gjt.sp.jedit.msg.BufferUpdate

History

Feedback

Please report bugs to the bug jEdit's plugin tracker on sourceforge.net