示例#1
0
        protected override async Task HandleResponse(string json, CancellationToken token)
        {
            var msg = EventResponse.Parse(json) ?? (dynamic)HeartbeatResponse.Parse(json) ?? TradeExecutionUpdate.Parse(json);

            if (msg != null)
            {
                await HandleResponse(msg);

                RechargePingPong();
            }
        }
        private async Task <dynamic> GetResponse()
        {
            var json = await Messenger.GetResponseAsync(CancellationToken);

            var result = EventResponse.Parse(json) ??
                         TickerResponse.Parse(json) ??
                         OrderBookSnapshotResponse.Parse(json) ??
                         (dynamic)OrderBookUpdateResponse.Parse(json) ??
                         HeartbeatResponse.Parse(json);

            return(result);
        }
示例#3
0
        protected override async Task HandleResponse(string json, CancellationToken token)
        {
            dynamic msg = null;

            try
            {
                msg = EventResponse.Parse(json) ?? (dynamic)HeartbeatResponse.Parse(json) ?? TradeExecutionUpdate.Parse(json);
            }
            catch (JsonSerializationException)
            {
                await _log.WriteWarningAsync(nameof(HandleResponse), "Unexpected message", json);
            }
            if (msg != null)
            {
                await HandleResponse(msg);

                RechargePingPong();
            }
        }
示例#4
0
        public static NetworkMessageBase Decode(string messageString)
        {
            if (string.IsNullOrWhiteSpace(messageString))
            {
                return(null);
            }

            var type = (NetworkMessageType)Enum.Parse(typeof(NetworkMessageType), GetTypeFromMsg(messageString));
            var msg  = GetMsgContent(messageString);

            switch (type)
            {
            case NetworkMessageType.ErrorResponse:                       return(ErrorResponse.Parse(msg));

            case NetworkMessageType.HeartbeatRequest:                    return(HeartbeatRequest.Parse(msg));

            case NetworkMessageType.HeartbeatResponse:                   return(HeartbeatResponse.Parse(msg));

            case NetworkMessageType.BeginConnectionRequest:              return(BeginConnectionRequest.Parse(msg));

            case NetworkMessageType.BeginConnectionResponse:             return(BeginConnectionResponse.Parse(msg));

            case NetworkMessageType.BeginDebugConnectionRequest:         return(BeginDebugConnectionRequest.Parse(msg));

            case NetworkMessageType.BeginDebugConnectionResponse:        return(BeginDebugConnectionResponse.Parse(msg));

            case NetworkMessageType.EndConnectionRequest:                return(EndConnectionRequest.Parse(msg));

            case NetworkMessageType.EndConnectionResponse:               return(EndConnectionResponse.Parse(msg));

            case NetworkMessageType.GetUserListRequest:                  return(GetUserListRequest.Parse(msg));

            case NetworkMessageType.GetUserListResponse:                 return(GetUserListResponse.Parse(msg));

            case NetworkMessageType.LoginRequest:                        return(LoginRequest.Parse(msg));

            case NetworkMessageType.LoginResponse:                       return(LoginResponse.Parse(msg));

            case NetworkMessageType.LogoutRequest:                       return(LogoutRequest.Parse(msg));

            case NetworkMessageType.LogoutResponse:                      return(LogoutResponse.Parse(msg));

            case NetworkMessageType.GetAppointmentsOfADayRequest:        return(GetAppointmentsOfADayRequest.Parse(msg));

            case NetworkMessageType.GetAppointmentsOfADayResponse:       return(GetAppointmentsOfADayResponse.Parse(msg));

            case NetworkMessageType.GetAppointmentsOfAPatientRequest:    return(GetAppointmentsOfAPatientRequest.Parse(msg));

            case NetworkMessageType.GetAppointmentsOfAPatientResponse:   return(GetAppointmentsOfAPatientResponse.Parse(msg));

            case NetworkMessageType.GetPatientListRequest:               return(GetPatientListRequest.Parse(msg));

            case NetworkMessageType.GetPatientListResponse:              return(GetPatientListResponse.Parse(msg));

            case NetworkMessageType.GetMedicalPracticeRequest:           return(GetMedicalPracticeRequest.Parse(msg));

            case NetworkMessageType.GetMedicalPracticeResponse:          return(GetMedicalPracticeResponse.Parse(msg));

            case NetworkMessageType.GetTherapyPlacesTypeListRequest:     return(GetTherapyPlacesTypeListRequest.Parse(msg));

            case NetworkMessageType.GetTherapyPlacesTypeListResponse:    return(GetTherapyPlacesTypeListResponse.Parse(msg));

            case NetworkMessageType.GetPracticeVersionInfoRequest:       return(GetPracticeVersionInfoRequest.Parse(msg));

            case NetworkMessageType.GetPracticeVersionInfoResponse:      return(GetPracticeVersionInfoResponse.Parse(msg));

            case NetworkMessageType.TryToAddNewEventsRequest:                        return(TryToAddNewEventsRequest.Parse(msg));

            case NetworkMessageType.TryToAddNewEventsResponse:                       return(TryToAddNewEventsResponse.Parse(msg));

            case NetworkMessageType.GetLockRequest:                                          return(GetLockRequest.Parse(msg));

            case NetworkMessageType.GetLockResponse:                                         return(GetLockResponse.Parse(msg));

            case NetworkMessageType.ReleaseLockRequest:                                      return(ReleaseLockRequest.Parse(msg));

            case NetworkMessageType.ReleaseLockResponse:                             return(ReleaseLockResponse.Parse(msg));

            case NetworkMessageType.GetLabelListRequest:                             return(GetLabelListRequest.Parse(msg));

            case NetworkMessageType.GetLabelListResponse:                            return(GetLabelListResponse.Parse(msg));

            case NetworkMessageType.EventBusNotification:                return(EventBusNotification.Parse(msg));

            case NetworkMessageType.PatientAddedNotification:            return(PatientAddedNotification.Parse(msg));

            case NetworkMessageType.PatientUpdatedNotification:          return(PatientUpdatedNotification.Parse(msg));

            case NetworkMessageType.TherapyPlaceTypeAddedNotification:   return(TherapyPlaceTypeAddedNotification.Parse(msg));

            case NetworkMessageType.TherapyPlaceTypeUpdatedNotification: return(TherapyPlaceTypeUpdatedNotification.Parse(msg));

            default:
                throw new ArgumentException();
            }
        }