| 372 | } |
| 373 | |
| 374 | TSharedPtr<FJsonObject> FURLabRpcDispatcher::Dispatch(const TSharedPtr<FJsonObject>& Req) |
| 375 | { |
| 376 | const double StartTime = FPlatformTime::Seconds(); |
| 377 | FString InOp = TEXT("<no-op>"); |
| 378 | if (Req.IsValid()) |
| 379 | Req->TryGetStringField(TEXT("op"), InOp); |
| 380 | UE_LOG(LogURLabNet, Log, TEXT("RPC -> %s"), *InOp); |
| 381 | |
| 382 | TSharedPtr<FJsonObject> Reply = DispatchInternal(Req); |
| 383 | |
| 384 | const double DurationMs = (FPlatformTime::Seconds() - StartTime) * 1000.0; |
| 385 | FString ReplyOp; |
| 386 | if (Reply.IsValid()) |
| 387 | Reply->TryGetStringField(TEXT("op"), ReplyOp); |
| 388 | |
| 389 | if (ReplyOp.Equals(TEXT("error"))) |
| 390 | { |
| 391 | FString Code, Message; |
| 392 | Reply->TryGetStringField(TEXT("code"), Code); |
| 393 | Reply->TryGetStringField(TEXT("message"), Message); |
| 394 | UE_LOG(LogURLabNet, Warning, |
| 395 | TEXT("RPC <- %s ERROR code=%s (%.1fms): %s"), |
| 396 | *InOp, *Code, DurationMs, *Message); |
| 397 | } |
| 398 | else |
| 399 | { |
| 400 | UE_LOG(LogURLabNet, Log, |
| 401 | TEXT("RPC <- %s -> %s (%.1fms)"), *InOp, *ReplyOp, DurationMs); |
| 402 | } |
| 403 | return Reply; |
| 404 | } |
| 405 | |
| 406 | TSharedPtr<FJsonObject> FURLabRpcDispatcher::DispatchInternal(const TSharedPtr<FJsonObject>& Req) |
| 407 | { |