Exemple #1
0
        void ProcessReturn(uint callId, BufferView data)
        {
            PendingCall callInfo = FetchPendingCall(callId);

            if (callInfo == null)
            {
                // Received a timeouted (or invalid) answer
                ProtocolError();
                return;
            }

            // Read the incoming data
            object inflatedData;

            try {
                inflatedData = InflateData.Inflate(data, callInfo.Call.ReturnFormat);
            } catch {
                ProtocolError();
                return;
            }

            // Clear the timeout
            if (callInfo.Interval != null)
            {
                callInfo.Interval.Stop();
            }

            // Call the callback
            if (callInfo.OnReturn != null)
            {
                callInfo.OnReturn(this, inflatedData);
            }
        }
Exemple #2
0
        void ProcessCall(uint callId, uint type, BufferView data)
        {
            object inflatedData;

            // Check the sequence id
            if (callId != ++LastReceivedId)
            {
                ProtocolError();
                return;
            }

            // Get call definition
            Registry.RegisteredCall call = Registry.GetServerCall(type);
            if (call == null)
            {
                ProtocolError();
                return;
            }

            // Read the incoming data
            try {
                inflatedData = InflateData.Inflate(data, call.ArgsFormat);
            } catch {
                ProtocolError();
                return;
            }

            // Emit the "call" event
            if (OnCall != null)
            {
                OnCall(this, new CallEventArgs(call, inflatedData, this, callId));
            }
        }
Exemple #3
0
        void ProcessException(uint callId, uint type, BufferView data)
        {
            PendingCall callInfo = FetchPendingCall(callId);

            if (callInfo == null)
            {
                // Received a timeouted (or invalid) answer
                ProtocolError();
                return;
            }
            if (!callInfo.Call.HasException(type))
            {
                // Received an invalid exception type
                ProtocolError();
                return;
            }

            // Get exception definition
            Registry.RegisteredException exception = Registry.GetException(type);
            if (exception == null)
            {
                ProtocolError();
                return;
            }

            // Read the incoming data
            object inflatedData;

            try {
                inflatedData = InflateData.Inflate(data, exception.DataFormat);
            } catch {
                ProtocolError();
                return;
            }

            // Clear the timeout
            if (callInfo.Interval != null)
            {
                callInfo.Interval.Stop();
            }

            // Call the callback
            if (callInfo.OnException != null)
            {
                callInfo.OnException(this, (int)type, inflatedData);
            }
        }