net_server: Clients can now check if a service is running.

* Using the new kMsgIsServiceRunning command.
This commit is contained in:
Axel Dörfler
2015-03-27 13:23:01 +01:00
parent 1f94cdcdff
commit c3ef93915b
3 changed files with 26 additions and 1 deletions
+2 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2015, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -20,6 +20,7 @@
#define kMsgJoinNetwork 'JNnw'
#define kMsgLeaveNetwork 'LVnw'
#define kMsgAutoJoinNetwork 'AJnw'
#define kMsgIsServiceRunning 'IRsv'
#endif // _NET_SERVER_H
+9
View File
@@ -304,6 +304,15 @@ NetServer::MessageReceived(BMessage* message)
break;
}
case kMsgIsServiceRunning:
{
// Forward the message to the handler that can answer it
BHandler* handler = fServices.Target(NULL);
if (handler != NULL)
handler->MessageReceived(message);
break;
}
default:
BApplication::MessageReceived(message);
return;
+15
View File
@@ -22,6 +22,8 @@
#include <NetworkAddress.h>
#include <NetworkSettings.h>
#include <NetServer.h>
using namespace std;
using namespace BNetworkKit;
@@ -196,6 +198,19 @@ Services::MessageReceived(BMessage* message)
_Update(*message);
break;
case kMsgIsServiceRunning:
{
const char* name = message->GetString("name");
if (name == NULL)
break;
BMessage reply(B_REPLY);
reply.AddString("name", name);
reply.AddBool("running", fNameMap.find(name) != fNameMap.end());
message->SendReply(&reply);
break;
}
default:
BHandler::MessageReceived(message);
}