spwtcppacketserver.cpp
68 lines
| 2.2 KiB
| text/x-c
|
CppLexer
r14 | /*------------------------------------------------------------------------------ | |||
-- This file is a part of the SocExplorer Software | ||||
-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | ||||
-- | ||||
-- 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 3 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
-------------------------------------------------------------------------------*/ | ||||
/*-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@member.fsf.org | ||||
----------------------------------------------------------------------------*/ | ||||
Jeandet Alexis
|
r12 | #include "spwtcppacketserver.h" | ||
#include "ui_spwtcppacketserver.h" | ||||
SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) : | ||||
QWidget(parent), | ||||
ui(new Ui::SpwTcpPacketServer) | ||||
{ | ||||
ui->setupUi(this); | ||||
Jeandet Alexis
|
r18 | this->p_bridge = NULL; | ||
this->p_server = new QTcpServer(); | ||||
connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer())); | ||||
Jeandet Alexis
|
r12 | } | ||
SpwTcpPacketServer::~SpwTcpPacketServer() | ||||
{ | ||||
delete ui; | ||||
} | ||||
Jeandet Alexis
|
r18 | |||
void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge) | ||||
{ | ||||
if(this->p_bridge!=NULL) | ||||
{ | ||||
disconnect(this,SLOT(pushPacket(char*,int))); | ||||
} | ||||
this->p_bridge = bridge; | ||||
connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int))); | ||||
} | ||||
void SpwTcpPacketServer::pushPacket(char *packet, int size) | ||||
{ | ||||
} | ||||
void SpwTcpPacketServer::toggleServer() | ||||
{ | ||||
if(this->p_server->isListening()) | ||||
{ | ||||
this->ui->startServeQpb->setText("Start Server"); | ||||
this->p_server->close(); | ||||
} | ||||
else | ||||
{ | ||||
this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt()); | ||||
this->ui->startServeQpb->setText("Stop Server"); | ||||
} | ||||
} | ||||