summaryrefslogtreecommitdiff
path: root/sappeer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sappeer.cc')
-rw-r--r--sappeer.cc67
1 files changed, 4 insertions, 63 deletions
diff --git a/sappeer.cc b/sappeer.cc
index af843e4..60e7660 100644
--- a/sappeer.cc
+++ b/sappeer.cc
@@ -132,7 +132,7 @@ void SAPPeer::acceptServiceConnection(SAPConnectionRequest *connReq, int statusC
resp.sessions.push_back(socket->sessionId());
}
- qDebug() << "acceptServiceConection" << statusCode;
+ qDebug() << "Accepting service conection with status" << statusCode;
writeToSession(SAProtocol::defaultSessionId,
SAProtocol::packServiceConnectionResponseFrame(resp));
@@ -227,7 +227,7 @@ void SAPPeer::handleDefaultSessionMessage(const QByteArray &message)
foreach (const SAProtocol::ServiceConnectionRequestSession &s, req.sessions) {
if (_sessions.contains(s.sessionId)) {
- qWarning() << "Requested session is already in use";
+ qWarning() << "Requested session" << s.sessionId << "is already active";
ok = false;
}
}
@@ -256,73 +256,14 @@ void SAPPeer::handleDefaultSessionMessage(const QByteArray &message)
// TODO set socket QoS parameters
conn->setSocket(s.channelId, socket);
+ qDebug() << " opening channel" << s.sessionId << s.channelId << "payload=" << s.payloadType;
+
_sessions.insert(s.sessionId, socket);
}
SAPConnectionRequest *connReq = new SAPConnectionRequest(conn, req.initiatorId, req.acceptorId);
agent->requestConnection(connReq);
-#if 0
- resp.messageType = SAProtocol::ServiceConnectionResponse;
- resp.acceptorId = req.acceptorId;
- resp.initiatorId = req.initiatorId;
- resp.profile = req.profile;
- resp.statusCode = 0;
-
- QList<SAPSocket*> created_sockets;
-
- SAPAgent *agent = _profiles.value(req.profile, 0);
- if (agent) {
- foreach (const SAProtocol::ServiceConnectionRequestSession &s, req.sessions) {
- if (_openSessions.contains(s.sessionId)) {
- // Session ID already used.
- resp.statusCode = 1;
- break;
- }
-
- SAPSocket *socket = new SAPSocket(this, s.sessionId, this);
-
- qDebug() << "Requesting connection to" << req.profile << s.channelId;
-
- if (!agent->acceptConnection(req.profile, s.channelId, socket)) {
- resp.statusCode = 2;
- break;
- }
-
- // Save for later. We can't emit the connected signal right now
- // because data might be written to the socket even before
- // we send the response.
- created_sockets.append(socket);
-
- resp.sessions.append(s.sessionId);
- }
-
- if (resp.statusCode != 0) {
- resp.sessions.clear(); // TODO Is this correct? Who knows!
- }
- }
-
- qDebug() << "Service connection request statusCode=" << resp.statusCode;
-
- writeToSession(SAProtocol::defaultSessionId,
- SAProtocol::packServiceConnectionResponseFrame(resp));
-
- if (resp.statusCode == 0) {
- foreach (SAPSocket *socket, created_sockets) {
- const int session = socket->sessionId();
- _openSessions.insert(session);
- qDebug() << "Session" << session << "now live";
-
- emit socket->connected();
- }
- } else {
- foreach (SAPSocket *socket, created_sockets) {
- emit socket->disconnected();
- socket->deleteLater();
- }
- }
-#endif
-
break;
}
case SAProtocol::ServiceConnectionResponse: {