◄ Previous: SNF's Connection(s)
Requests are the messages sent back and forth between the client and the server which allows them to communicate, this page will show a step by step on how to generate them, edit them, and as for sending those requests Check Practical Example
- Note
- Always makesure your opcodes and the server is up and running and connected before sending any request !
Generating a Request
There is X different overload to create a new Request for different usecases
Generating a Request with just an OPCode and doesnt await a response
This requires you 1 Argument
- An `OPCODE Object`
Request req = new Request(
<OPCODE Object>
);
Generating a Request with just an OPCode and awaits a response
This requires you 2 Arguments
- An `OPCODE Object`
- Request Callback that would be called upon server response You can either:
1- Declare an appropriate function and pass it as an argument
eg of a function Declaration
public void NameOfYourCallBack(Request Response)
{
...
...
}
and then pass it as an argument upon the creation of the request object
Request req = new Request(
<OPCODE Object>,
NameOfYouCallBack
);
2- Declare the function directly in the arguents
eg
Request req = new Request(
<OPCODE Object>,
(Request Response) => {
...
...
}
);
Generating a Request with an OPCode, Arguments and doesnt await a response
This requires you 2 Arguments
- An `OPCODE Object`
- An array of
byte[]
. Each byte[]
being an SNF Argument
byte[][] args =
{
new byte[] { 0x22, 0x33},
Encoding.ASCII.GetBytes("Argument From String"),
.
.
};
Request req = new Request(
<OPCODE Object>,
args
);
Generating a Request with an OPCode, Arguments and awaits a response
This requires you 2 Arguments
- An `OPCODE Object`
- An array of
byte[]
. Each byte[]
being an SNF Argument
- Request Callback that would be called upon server response
Request req = new Request(
<OPCODE Object>,
args,
Callback
);
Generating a Request with a custom UID
You can Set a Custom Request by Defining the byte array that has the length stated in the Variable SNFClient::Request::_UID_LENGTH and pass it as the first argument in either one of the Constructors that allows a Custom UID
- Note
- All Requests(Except those generated with a CustomUID) Will have an auto incrementing Unique UID generated by the generateUID() Function.
First generate your UID
byte [] UID = new byte[Request._UID_LENGTH];
..
..
Then if you want a Request that doesnt Await a response, create it like this:
Requiring 2 Arguments other than the Custom UID
- An `OPCODE Object`
- An array of
byte[]
. Each byte[]
being an SNF Argument - Note
- If you dont have an argument then put
null
instead of args
Request req = new Request(
UID,
<OPCODE Object>,
args
);
and if you want a Request that Awaits a response, create it like this:
Requiring 3 Arguments other than the Custom UID
- An `OPCODE Object`
- An array of
byte[]
. Each byte[]
being an SNF Argument
- Request Callback that would be called upon server response
Request req = new Request(
UID,
<OPCODE Object>,
args,
Callback
);
Making use of your Request
After you have genrated the Request object to your needs, you can send it using " \ref T-CON6 "