You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Wechaty ecosystem is involved very fast in the past months, we have lots of new features and bug fixes.
It is well designed and decoupled, that's why we can support multi-language and more and more puppet protocols without any difficulty.
However, sometimes we want to call the puppet methods freely and without any limitations, for example:
We need to call some puppet methods for debugging
We need to provide a new puppet feature very quickly (without modifying the puppet base class and the GRPC service)
We want to test some puppet specified methods
etc.
The Problem
If you want to call a puppet provider from Wechaty, what you can do is:
(wechaty.puppetasany).XXXMethod()
Which XXXMethod() is the method you want to call from your puppet. By using the wechaty.puppet as any trick, we can call any method on the puppet, even the private methods.
However, this is not deep enough when we are using the Hostie Puppet.
The hostie puppet is using the GRPC for providing a deeper decouple between Wechaty and puppets, which means that the Wechaty.puppet can not reach the real puppet behind the GRPC service.
The Solution
This solution came out when I have Chongqing hot pot with @lijiarui and @qhduan.
We can use our ding() method and the dong event to build an RPC channel between the Wechaty and the deepest puppet provider.
The design of the ding/dong mechanism is:
wechaty.ding(data: string) is a method that can be called with a string parameter, on the Wechaty
the ding() will be called on the puppet that provides the service to this Wechaty, the deepest one behind the GRPC service
the puppet behind the GRPC service then will be able to emit a dong event, with a data payload, to pass a string back
the wechaty will receive a dong event, with the same data payload from the puppet.
This lets us be able to build a channel to send/receive string data between the wechaty and puppet.
Then we can use a JSON-GRPC to do any remote grpc call based on this channel.
Conclusion
After I got this idea, I think it will be the best way to add the maximum flexibility to our Wechaty system for doing anything between the Wechaty and the puppet.
Will consider building an example with JSON-RPC to demonstrate this idea.
The text was updated successfully, but these errors were encountered:
Background
The Wechaty ecosystem is involved very fast in the past months, we have lots of new features and bug fixes.
It is well designed and decoupled, that's why we can support multi-language and more and more puppet protocols without any difficulty.
However, sometimes we want to call the puppet methods freely and without any limitations, for example:
The Problem
If you want to call a puppet provider from Wechaty, what you can do is:
Which
XXXMethod()
is the method you want to call from your puppet. By using thewechaty.puppet as any
trick, we can call any method on the puppet, even theprivate
methods.However, this is not deep enough when we are using the Hostie Puppet.
The hostie puppet is using the GRPC for providing a deeper decouple between Wechaty and puppets, which means that the
Wechaty.puppet
can not reach the real puppet behind the GRPC service.The Solution
This solution came out when I have Chongqing hot pot with @lijiarui and @qhduan.
We can use our
ding()
method and thedong
event to build an RPC channel between the Wechaty and the deepest puppet provider.The design of the
ding/dong
mechanism is:wechaty.ding(data: string)
is a method that can be called with a string parameter, on the Wechatyding()
will be called on the puppet that provides the service to this Wechaty, the deepest one behind the GRPC servicedong
event, with adata
payload, to pass a string backwechaty
will receive adong
event, with the same data payload from the puppet.This lets us be able to build a channel to send/receive string data between the wechaty and puppet.
Then we can use a JSON-GRPC to do any remote grpc call based on this channel.
Conclusion
After I got this idea, I think it will be the best way to add the maximum flexibility to our Wechaty system for doing anything between the Wechaty and the puppet.
Will consider building an example with JSON-RPC to demonstrate this idea.
The text was updated successfully, but these errors were encountered: