Delegate EncodeClientProcedure
User defined callback function to receive notification of client connections and disconnections, and optionally refuse connections.
Namespace: System.Dynamic.ExpandoObject
Assembly: ManagedBass.Enc.dll
Syntax
public delegate bool EncodeClientProcedure(int Handle, bool Connect, string Client, IntPtr Headers, IntPtr User);
Parameters
Int32
Handle
The encoder/server that the client is connecting to or disconnecting from. |
Boolean
Connect
The client is connecting? true = connecting, false = disconnecting. |
String
Client
The client's IP address and port number... "IP:port". |
IntPtr
Headers
The request headers... null = the client is disconnecting or HTTP headers have been disabled via the NoHTTP flag. The headers are in the same form as would be given by ChannelGetTags(Int32, TagType), which is a series of null-terminated strings, the final string ending with a double null. The request headers can optionally be replaced with response headers to send back to the client, each ending with a carriage return and line feed ("\r\n"). The response headers should not exceed 1KB in length. |
IntPtr
User
The user instance data given when ServerInit(Int32, String, Int32, Int32, EncodeServer, EncodeClientProcedure, IntPtr) was called. |
Returns
Boolean
If the client is connecting, false means the connection is denied, otherwise it is accepted. The return value is ignored if the client is disconnecting. |
Remarks
This function can be used to keep track of how many clients are connected, and who is connected. The request headers can be used to authenticate clients, and response headers can be used to pass information back to the clients. By default, connecting clients will be sent an "HTTP/1.0 200 OK" status line if accepted, and an "HTTP/1.0 403 Forbidden" status line if denied. That can be overridden in the first response header.
Disconnection notifications will be received for clients that have disconnected themselves or that have been kicked by ServerKick(Int32, String), but there will no notification of any clients that are disconnected by the encoder being freed.
Each server has its own thread that handles new connections and sends data to its clients. The notification callbacks also come from that thread, so the callback function should avoid introducing long delays as that could result in clients missing some data and delay other clients connecting.
Use ExtractMultiStringAnsi(IntPtr) to get the Headers
.