Televiska / viska

SIP framework built in Rust
Other
88 stars 9 forks source link

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

Open gswy opened 4 months ago

gswy commented 4 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 4 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(() => {
// 
})