trikRuntime
mailboxConnection.h
Go to the documentation of this file.
1 /* Copyright 2014 - 2015 CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QObject>
18 #include <QtCore/QScopedPointer>
19 #include <QtNetwork/QTcpSocket>
20 
21 #include "connection.h"
22 
23 namespace trikNetwork {
24 
27 {
28  Q_OBJECT
29 
30 public:
32 
34  Q_INVOKABLE void connect(const QHostAddress &targetIp, int targetPort, int myServerPort, int myHullNumber);
35 
37  Q_INVOKABLE void sendConnectionInfo(const QHostAddress &ip, int port, int hullNumber);
38 
40  Q_INVOKABLE void sendSelfInfo(int hullNumber);
41 
42 signals:
48  void newConnection(const QHostAddress &ip, int clientPort, int serverPort, int hullNumber);
49 
51  void connectionInfo(const QHostAddress &ip, int port, int hullNumber);
52 
54  void newData(const QHostAddress &ip, int port, const QByteArray &data);
55 
56 private:
57  void processData(const QByteArray &data) override;
58 };
59 
60 }
static const int port
Definition: trikCommunicatorTest.cpp:24
One connection to a client (or server) in mailbox. Supposed to be working in a separate thread...
Definition: mailboxConnection.h:26
Q_INVOKABLE void sendSelfInfo(int hullNumber)
Send our hull number. Used in response for connection request.
Definition: mailboxConnection.cpp:42
Q_INVOKABLE void connect(const QHostAddress &targetIp, int targetPort, int myServerPort, int myHullNumber)
Connect to given endpoint and send "register" command with our mailbox server port and hull number...
Definition: mailboxConnection.cpp:28
Definition: trikCommunicator.h:31
MailboxConnection()
Definition: mailboxConnection.cpp:23
void newData(const QHostAddress &ip, int port, const QByteArray &data)
Emitted when new data message received ("data" command).
void newConnection(const QHostAddress &ip, int clientPort, int serverPort, int hullNumber)
Emitted when "register" command is received.
Q_INVOKABLE void sendConnectionInfo(const QHostAddress &ip, int port, int hullNumber)
Send info about other robot: its IP, port and hull number.
Definition: mailboxConnection.cpp:36
Abstract class that serves one client of TrikServer.
Definition: connection.h:50
void connectionInfo(const QHostAddress &ip, int port, int hullNumber)
Emitted when remote robot sends info about other known robots ("connection" command).