SendCall() public static method

public static SendCall ( Socket in_socket, GbxCall in_call ) : int
in_socket System.Net.Sockets.Socket
in_call GbxCall
return int
Beispiel #1
0
        /// <summary>
        /// Sends a request to the server and blocks until a response has been received.
        /// </summary>
        /// <param name="inMethodName">The method to call.</param>
        /// <param name="inParams">Parameters describing your request.</param>
        /// <returns>Returns a response object from the server.</returns>
        public GbxCall Request(string inMethodName, object[] inParams)
        {
            // reset event ...
            callRead.Reset();

            // send the call and remember the handle we are waiting on ...
            GbxCall Request = new GbxCall(inMethodName, inParams);

            Request.Handle = --this.requests;
            int handle = XmlRpc.SendCall(this.tcpSocket, Request);

            // wait until we received the call ...
            do
            {
                callRead.WaitOne();
            } while (responses[handle] == null && tcpSocket.Connected);

            // did we get disconnected ?
            if (!tcpSocket.Connected)
            {
                throw new NotConnectedException();
            }

            // get the call and return it ...
            return(GetResponse(handle));
        }
Beispiel #2
0
        /// <summary>
        /// Sends a Request and does not wait for a response of the server.
        /// The response will be written into a buffer or you can set a callback method
        /// that will be executed.
        /// </summary>
        /// <param name="inMethodName">The method to call.</param>
        /// <param name="inParams">Parameters describing your request.</param>
        /// <param name="callbackHandler">An optional delegate which is callen when the response is available otherwise set it to null.</param>
        /// <returns>Returns a handle to your request.</returns>
        public int AsyncRequest(string inMethodName, object[] inParams, GbxCallCallbackHandler callbackHandler)
        {
            // send the call and remember the handle ...
            GbxCall Request = new GbxCall(inMethodName, inParams);

            Request.Handle = --this.requests;
            int handle = XmlRpc.SendCall(this.tcpSocket, Request);

            lock (this)
            {
                if (handle != 0)
                {
                    // register a callback on this request ...
                    if (callbackHandler != null)
                    {
                        callbackList.Add(handle, callbackHandler);
                    }

                    // return handle id ...
                    return(handle);
                }
                else
                {
                    return(0);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// (Dis)activates callbacks from the server.
        /// </summary>
        /// <param name="inState">Whether to receive callbacks from the server.</param>
        /// <returns>Returns new callback state</returns>
        public bool EnableCallbacks(bool inState)
        {
            GbxCall EnableCall = new GbxCall("EnableCallbacks", new object[] { inState });

            EnableCall.Handle = --this.requests;
            return(XmlRpc.SendCall(this.tcpSocket, EnableCall) != 0);
        }