Пример #1
0
 internal static void OnResponse(ResponseInfo ri)
 {
     // maybe this blows up if return type is void or maybe it returns null?
     object rv = Json.FromJson(ri.ReturnValue, ri.ReturnType);
     InvokeMethod(ri.Callback, "OnSuccess", ri.ReturnType, rv);
 }
Пример #2
0
        internal static void OnChunkedResponse(ResponseInfo ri)
        {
            if(ri.IsFirstChunk)
            {
                InvokeMethod(ri.Callback, "OnStart", typeof(int), ri.TotalItemCount);
            }

            OnResponse(ri);

            if(ri.IsResponseComplete)
            {
                InvokeMethod(ri.Callback, "OnFinish", typeof(void), null);
            }
        }
Пример #3
0
 internal static void OnException(ResponseInfo ri)
 {
     Exception e = new Exception(ri.ReturnValue);
     InvokeMethod(ri.Callback, "OnException", e.GetType(), e);
 }
Пример #4
0
        /// <summary> 
        /// Unpack the message 
        /// </summary>
        private ResponseInfo Unpack(IMapMessage m)
        {
            ResponseInfo ri = new ResponseInfo();
            ri.CorrelationId = m.NMSCorrelationID;
            ri.SessionId = m.Body.GetString(ProtocolParams.SessionId);
            ri.IsBroadcast = m.Body.GetBool(ProtocolParams.IsBroadcast);
            ri.ReturnValue = m.Body.GetString(ProtocolParams.ReturnValue);
            ri.IsException = m.Body.GetBool(ProtocolParams.IsException);
            ri.IsChunked = m.Body.GetBool(ProtocolParams.IsChunked);
            ri.IsResponseComplete = m.Body.GetBool(ProtocolParams.IsResponseComplete);
            if(ri.IsChunked)
            {
                ri.IsFirstChunk = m.Body.GetBool(ProtocolParams.IsFirstChunk);
            }
            if(ri.IsFirstChunk)
            {
                ri.TotalItemCount = m.Body.GetInt(ProtocolParams.TotalItemCount);
            }

            return ri;
        }
Пример #5
0
 /// <summary>
 /// Discard the response if it's not a broadcast msg and sessionId is not ours.
 /// </summary>
 private bool ShouldDiscardResponse(ResponseInfo ri)
 {
     if(ri.IsBroadcast) { return false; }
     Preconditions.NotNull(ri.SessionId,"Reply msg did not have sessionId");
     return ri.SessionId != this.SessionId;
 }
Пример #6
0
 private void RmCallback(ResponseInfo ri)
 {
     if(!callbackDict.ContainsKey(ri.CorrelationId)) { return; }
     callbackDict.Remove(ri.CorrelationId);
 }
Пример #7
0
 private void HandleResponse(ResponseInfo ri)
 {
     ResponseDelegate del = ResponseHandler.OnResponse;
     this.ThreadStrategy.Exec(del, ri);
 }
Пример #8
0
 /// <summary>
 /// Invoke the callback's OnException
 /// </summary>
 private void HandleException(ResponseInfo ri)
 {
     ExceptionDelegate del = ResponseHandler.OnException;
     this.ThreadStrategy.Exec(del, ri);
 }