Televiska / viska

SIP framework built in Rust
Other
87 stars 8 forks source link

Will there be a method similar to HTTP request response. #44

Open gswy opened 2 months ago

gswy commented 2 months ago

After using the jain sip ri library in Java, I found that whether on the client or server side, sending a MESSAGE request to the destination requires a dependency on the Response callback provided by the library. At this point, the relationship between Request and Response needs to be bound in the business code. As a user, I find it difficult to maintain binding relationships in this way. So can the following example (pseudocode) be provided at the 'viska' framework layer:

Response resp = sip.request(sip);
gswy commented 2 months ago

I don't know if this complies with some standards, but as a user, it is indeed much more user-friendly. I suddenly realized that I could learn from the promise usage in JavaScript.

sip.request(request).then((resp) => {
// TODO
}).catch((e) => {
// handle error: timeout/status err
}).finally(() => {
// 
})