When dispatching the secure data: Accept.dispatchData(secureData, callback);
is there a way to send custom data along with the secureData to your callback?
No, userFields would be included in the createTransactionRequest after receiving the nonce.
Accept.js gives you control over the user experience using your own form, but avoids any sensitive card data passing through your server.
Related
is it possible to define how the verification code will be sent when calling the LoginUserIfNeeded method? I need to send it via SMS and not to the application.
Telegram servers decide by themselves through which method to send the code initially.
However if the user did not receive the code (eventually after a given timeout), he can request the code to be sent through an alternative method:
In WTelegramClient, this is done by returning an empty string for "verification_code" (typically, only on the first try)
You should probably first check through which medium Telegram sent the code:
The client.OnUpdate event receives a Auth_SentCode object specifying details (type) about the transmitted verification code. Then you can decide to reply the empty string only if it was transmitted through a medium you don't have access to.
You can check via the Auth_SentCode.next_type field which method will be used to send the code on the next try. (and you can possibly reply an empty verification_code again to try yet another method)
Additionally, on the call to LoginUserIfNeeded you can pass a CodeSettings instance which offer some limited options about the enabled methods for sending of the code.
Consider a POST/PUT REST API (using DRF).
If the server receives request1 and within a couple of ms request2 with identical everything to request1 (duplicate request), is there a way to avoid the request2 to be executed using some Django way? Or Should I deal with it manually by some state?
Any inputs would be much appreciated.
There isn't anything out of the box so you would need to write something your self potentially a piece of custom middleware (https://docs.djangoproject.com/en/3.0/topics/http/middleware/) would be best as then it would run over all of the requests. You would need to capture and exam the requests so you'd need a fast storage of some sort such as a memory store.
You could also look into the python asynco library - https://docs.python.org/3/library/asyncio-sync.html
Another possible solution would be using a FIFO message queue which is configured to support de-duplication based on content. This would turn the request into an deferred process though so it may not be suitable for your needs.
Using Async bidirectional streaming, can i create a client stream (ClientAsyncReaderWriter) and modify metadata value in ClientContext for each request sent on that stream? Also, on the server side, can i use the ServerContext of the incoming client stream, to send modified metadata value for each response sent back to the client on the bidiriectional stream. Please let me know if there is a way to do this since i dont want to maintain multiple streams for each of the metadata value. I would like to use same stream and send different metadata value for a key for each request/response exchanged on that bidirectional stream.
This is intentionally not supported.
Metadata is intended to be at the RPC layer per bidi stream; not per req/response. If you wish to communicate information per req/response, you should put that inside the req/response.
Metadata is intended to be for all req/response in the same stream.
Metadata is tied to stream; please see documentation https://github.com/grpc/grpc/blob/master/CONCEPTS.md#abstract-grpc-protocol
There is the client interceptor
https://github.com/grpc/grpc/blob/master/include/grpcpp/impl/codegen/client_interceptor.h
which may be able to help
These tests show examples how the interceptors can be used:
https://github.com/grpc/grpc/blob/master/test/cpp/end2end/client_interceptors_end2end_test.cc
I have a function to give recommendations to users. This function need to make a lot of calcs to start, but after start it use the already calculed matrix on memory. After this, any other calc that is made, "fills" the object in memory to continuous learning.
My intention is to use this function to website users, but the response need to come from the same "object" in memory and need to be sequential by request because it is not thread safe.
How is the best way to get this working? My first idea was use signalr so the user dont need to wait to response and a queue to send the requests to objects. But how the signalr can receive the response for this specific request?
The entire flow is:
User enter on a page.
A javascript will call a service with the user ID and actual page.
The server will queue the ID an page.
The service will be calculating the results for each request on queue and sending responses.
The server will "receive" the response and send back to client.
The main problem is that I dont see a way to the service receive the response to send back to client until it is complete, without need to be looping in queues.
Thanks!
If you are going to use SignalR, I would suggest using a hub method to accept these potentially long running requests from the client. By doing so it should be obvious "how the signalr can receive the response for this specific request".
You should be able to queue your calculations from inside your hub method where you will have access to the caller's connection id (via the Context.ConnectionId property).
If you can await the results of your queued operation inside of the hub method you queue from, you can then simply return the result from your hub method and SignalR will flow the result back to the calling JavaScript. You can also use Clients.Caller.... to send the result back.
If you go this route I suggest you use async/await instead of blocking request threads waiting for your long-running calculations to complete.
http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server
If you can't process your calculation results from the same method you queued the calculation from, you still have options. Just be sure to queue the caller's connection id and a request id along with the calculation to be processed.
Then, you can process the results of all your calculations from outside of your hub using GlobalHost.ConnectionManager.GetHubContext:
private IHubContext _context = GlobalHost.ConnectionManager.GetHubContext<MyHub>()
// Call ProcessResults whenever results are ready to send back to the client
public void ProcessResults(string connectionId, uint requestId, MyResult result)
{
// Presumably there's JS code mapping request id's to results
// if you can have multiple ongoing requests per client
_context.Clients.Client(connectionId).receiveResult(requestId, result);
}
http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server#callfromoutsidehub
I have a requirement to count the jetty transactions and measure the time it took to process the request and get back the response using JMX for our monitoring system.
I am using Jetty 8.1.7 and I can’t seem to find a proper way to do this. I basically need to identify when request is sent (due to Jetty Async approach this is triggered from thread A) and when the response is complete (as the oncompleteResponse is done in another thread).
I usually use ThreadLocal for such state in other areas I need similar functionality, but obviously this won’t work here.
Any ideas how to overcome?
To use jetty's async requests you basically have to subclass ContentExchange and override its methods. So you can add an extra field to it which would contain a timestamp of when the request was sent, and use it later in your onResponseComplete() method to measure the processing time. If you need to know the time when your request was actually sent to the server instead of when it was created you can override the onRequestCommitted() and onRequestComplete() methods.