Beispiel #1
0
        public Result onQuery(string command, byte[] request)
        {
            Result result = new Result();

            Plugin.QueryRequestMessage request_message = Plugin.QueryRequestMessage.CreateBuilder().MergeFrom(request).Build();
            log.debug("Got command: " + command);

            Plugin.QueryResponseMessage.Builder response_message = Plugin.QueryResponseMessage.CreateBuilder();
            response_message.SetHeader(Plugin.Common.Types.Header.CreateBuilder().Build());
            Plugin.QueryResponseMessage.Types.Response.Builder response = Plugin.QueryResponseMessage.Types.Response.CreateBuilder();
            response.SetCommand(command);
            response.SetResult(Plugin.Common.Types.ResultCode.OK);
            response.AddLines(Plugin.QueryResponseMessage.Types.Response.Types.Line.CreateBuilder().SetMessage("Hello from C#").Build());
            response_message.AddPayload(response.Build());

            return(new Result(response_message.Build().ToByteArray()));
        }
Beispiel #2
0
        public NSCP.Result onQuery(string command, byte[] request)
        {
            NSCP.Result result = new NSCP.Result();
            Plugin.QueryRequestMessage request_message = Plugin.QueryRequestMessage.CreateBuilder().MergeFrom(request).Build();
            string intcommand = request_message.GetPayload(0).Command;

            core.getLogger().error("Got command: " + intcommand + "/" + command);

            Plugin.Common.Types.Header.Builder header = Plugin.Common.Types.Header.CreateBuilder();
            header.SetVersion(Plugin.Common.Types.Version.VERSION_1);

            Plugin.QueryResponseMessage.Builder response_message        = Plugin.QueryResponseMessage.CreateBuilder();
            Plugin.QueryResponseMessage.Types.Response.Builder response = Plugin.QueryResponseMessage.Types.Response.CreateBuilder();
            response.SetCommand(command);
            response.SetResult(Plugin.Common.Types.ResultCode.OK);
            response.SetMessage("Hello from C#");
            response_message.AddPayload(response.Build());
            response_message.SetHeader(header.Build());

            result.data   = response_message.Build().ToByteArray();
            result.result = 1;
            return(result);
        }