@@ -2,6 +2,7 @@ package wechaty.padplus.support
2
2
3
3
import java .io .{File , FileOutputStream }
4
4
import java .util
5
+ import java .util .concurrent .{CountDownLatch , TimeUnit }
5
6
6
7
import com .google .zxing .client .j2se .BufferedImageLuminanceSource
7
8
import com .google .zxing .common .HybridBinarizer
@@ -23,11 +24,15 @@ import wechaty.puppet.{Puppet, ResourceBox}
23
24
* @since 2020-06-21
24
25
*/
25
26
trait GrpcEventSupport extends StreamObserver [StreamResponse ]{
26
- self : GrpcSupport with Puppet with LazyLogging =>
27
+ self : GrpcSupport with LocalStoreSupport with Puppet with LazyLogging =>
27
28
29
+ private val countDownLatch = new CountDownLatch (1 )
28
30
31
+
32
+ protected def awaitStreamStart ()= countDownLatch.await(10 ,TimeUnit .SECONDS )
29
33
override def onNext (response : StreamResponse ): Unit = {
30
34
logger.debug(" stream response:{}" ,response)
35
+ countDownLatch.countDown()
31
36
32
37
val traceId = response.getTraceId
33
38
if (! isBlank(traceId)){
@@ -62,7 +67,7 @@ trait GrpcEventSupport extends StreamObserver[StreamResponse]{
62
67
logger.debug(" Scan QR Code to login: %s\n https://api.qrserver.com/v1/create-qr-code/?data=%s\n " .format(payload.status, payload.qrcode))
63
68
emit(PuppetEventName .SCAN ,payload)
64
69
case _ =>
65
- // val uin = response.getUin( )
70
+ saveUin( response.getUinBytes )
66
71
// val user = objectMapper.readTree(response.getData())
67
72
// val userName = user.get("userName").asText()
68
73
0 commit comments