1
0
Fork 0
flightgear/src/Network/protocol.cxx
curt f9f05aa870 Bernie Bright:
Here is the new super improved telnet property interface.  CVS changelog
is at the end of this message.  Once this new telnet code is in and
compiles every where we can remove Network/props.[ch]xx.  I've added a
--telnet=<port> command line option to invoke the new server.  Later on
we could remove the --props option, or least change it to invoke the new
server.  I'll let you decide.

I've added some new commands to the telnet interface:

view next      Select the next view.
view prev      Select the previous view.
view set <n>   Select view 'n'
view get       Return index of current view

I'm not sure if these same effects could be achieved through property
operations.  The commands provide a convenient shortcut in any case.

I'm also planning on adding a panel command to manipulate panels and
objects contained therein (eg simulated mouse clicks).  There is going
to be some commonality with the command objects so we may need to
rationalize this in the near future.

Finally, I've also included my python stuff.  This is still very much a
work in progress, basically I've been using it to test the new telnet
server.  I have  tested it with python 2.2.  Feel free to add it to the
repository if you want.  I would suggest a scripts/python directory

CVS Changelog

Network/telnet.cxx: New property telnet protocol interface.  It supports
the same user interface provided by the --props server.  Additionally it
handles multiple simultaneous connections.  Added "view" command to
manipulate viewmgr.

Network/protocol.hxx: Added protocol configuration exception.

Main/fg_io.cxx:  Added new "telnet" protocol.  Added protocol
configuration parse exceptions.  Simplified protocol configuration
parsing.

Main/options.cxx: Added --telnet=<port> command line option and help
message.
2002-05-15 21:44:34 +00:00

108 lines
2.3 KiB
C++

// protocol.cxx -- High level protocal class
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
#include <simgear/debug/logstream.hxx>
#include <simgear/io/iochannel.hxx>
#include "protocol.hxx"
FGProtocol::FGProtocol() :
hz(0.0),
count_down(0),
enabled(false)
{
}
FGProtocol::~FGProtocol() {
}
// standard I/O channel open routine
bool FGProtocol::open() {
if ( is_enabled() ) {
SG_LOG( SG_IO, SG_ALERT, "This shouldn't happen, but the channel "
<< "is already in use, ignoring" );
return false;
}
SGIOChannel *io = get_io_channel();
if ( ! io->open( get_direction() ) ) {
SG_LOG( SG_IO, SG_ALERT, "Error opening channel communication layer." );
return false;
}
set_enabled( true );
return true;
}
// dummy process routine
bool FGProtocol::process() {
SG_LOG( SG_IO, SG_INFO, "dummy FGProtocol::process()" );
return false;
}
// dummy close routine
bool FGProtocol::close() {
SG_LOG( SG_IO, SG_INFO, "dummy FGProtocol::close()" );
return false;
}
// standard I/O channel close routine
bool FGProtocol::gen_message() {
SGIOChannel *io = get_io_channel();
set_enabled( false );
if ( ! io->close() ) {
return false;
}
return true;
}
// dummy close routine
bool FGProtocol::parse_message() {
SG_LOG( SG_IO, SG_INFO, "dummy FGProtocol::close()" );
return false;
}
void FGProtocol::set_direction( const string& d ) {
if ( d == "in" ) {
dir = SG_IO_IN;
} else if ( d == "out" ) {
dir = SG_IO_OUT;
} else if ( d == "bi" ) {
dir = SG_IO_BI;
} else {
dir = SG_IO_NONE;
}
}