Skip to content

Commit

Permalink
Handle service unavailable case when sending message, thanks to EDG (#…
Browse files Browse the repository at this point in the history
…1659)

* Handle server busy case in sending message, thanks to EDG

* Rename to ServiceUnavailable and throw ServiceUnavailableException

* Rename to ServiceUnavailable

* Remove ServiceUnavailableException, replace with IllegalStateException
  • Loading branch information
sandtechnology authored Nov 9, 2021
1 parent ef2d22c commit 57a20ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ internal abstract class SendMessageHandler<C : Contact> {
}
}
}
if (resp is MessageSvcPbSendMsg.Response.ServiceUnavailable){
throw IllegalStateException("Send message to $contact failed, server service is unavailable.")
}
if (resp is MessageSvcPbSendMsg.Response.Failed) {
val contact = contact
when (resp.resultType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory<MessageSvcPbSendMsg.
object MessageTooLarge : Response() {
override fun toString(): String = "MessageSvcPbSendMsg.Response.MessageTooLarge"
}
object ServiceUnavailable : Response() {
override fun toString(): String = "MessageSvcPbSendMsg.Response.ServiceUnavailable"
}

/**
* 121: 被限制? 个别号才不能发
Expand Down Expand Up @@ -463,6 +466,7 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory<MessageSvcPbSendMsg.
return when (response.result) {
0 -> Response.SUCCESS
10 -> Response.MessageTooLarge
32 -> Response.ServiceUnavailable
else -> Response.Failed(
response.result,
response.errtype,
Expand Down

0 comments on commit 57a20ea

Please sign in to comment.