import{_ as e,o as n,c as a,e as c}from"./app-ClSKFI0Z.js";const l={},t=c(`

def set_channel(name: str, channel: Channel) -> None

设置通道实例

Args:

name: 通道名称

channel: 通道实例

def set_channels(channels: dict[str, Channel]) -> None

设置通道实例

Args:

channels: 通道名称

def get_channel(name: str) -> Channel

获取通道实例

Args:

name: 通道名称

Returns:

def get_channels() -> dict[str, Channel]

获取通道实例

Returns:

def on_set_channel(data: tuple[str, dict[str, Any]]) -> None

def on_get_channel(data: tuple[str, dict[str, Any]]) -> None

def on_get_channels(data: tuple[str, dict[str, Any]]) -> None

def decorator(func: Callable[[T], Any]) -> Callable[[T], Any]

async def wrapper(data: T) -> Any

class Channel(Generic[T])

通道类,可以在进程间和进程内通信,双向但同时只能有一个发送者和一个接收者

有两种接收工作方式,但是只能选择一种,主动接收和被动接收,主动接收使用 receive 方法,被动接收使用 on_receive 装饰器

def __init__(self, _id: str, type_check: bool) -> None

 初始化通道

Args:

_id: 通道ID

def send(self, data: T) -> None

 发送数据

Args:

data: 数据

def receive(self) -> T

 接收数据

Args:

def close(self) -> None

 关闭通道

def on_receive(self, filter_func: Optional[FILTER_FUNC]) -> Callable[[Callable[[T], Any]], Callable[[T], Any]]

 接收数据并执行函数

Args:

filter_func: 过滤函数,为None则不过滤

Returns:

装饰器,装饰一个函数在接收到数据后执行

var T = TypeVar('T')

var channel_deliver_active_channel = Channel(_id='channel_deliver_active_channel')

var channel_deliver_passive_channel = Channel(_id='channel_deliver_passive_channel')

var recv_chan = data[1]['recv_chan']

var recv_chan = Channel[Channel[Any]]('recv_chan')

var recv_chan = Channel[dict[str, Channel[Any]]]('recv_chan')

var data = self.conn_recv.recv()

var func = _callback_funcs[func_id]

var func = _callback_funcs[func_id]

var data = self.conn_recv.recv()

var data = self.conn_recv.recv()

`,54),r=[t];function s(d,h){return n(),a("div",null,r)}const i=e(l,[["render",s],["__file","channel.html.vue"]]),f=JSON.parse(`{"path":"/dev/api/comm/channel.html","title":"liteyuki.comm.channel","lang":"zh-CN","frontmatter":{"title":"liteyuki.comm.channel","order":1,"icon":"laptop-code","category":"API","description":"def set_channel(name: str, channel: Channel) -> None 设置通道实例 Args: def set_channels(channels: dict[str, Channel]) -> None 设置通道实例 Args: def get_channel(name: str) -> Channel 获取通道实...","head":[["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/dev/api/comm/channel.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot 轻雪机器人"}],["meta",{"property":"og:title","content":"liteyuki.comm.channel"}],["meta",{"property":"og:description","content":"def set_channel(name: str, channel: Channel) -> None 设置通道实例 Args: def set_channels(channels: dict[str, Channel]) -> None 设置通道实例 Args: def get_channel(name: str) -> Channel 获取通道实..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2024-08-19T02:22:24.000Z"}],["meta",{"property":"article:modified_time","content":"2024-08-19T02:22:24.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.comm.channel\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-19T02:22:24.000Z\\",\\"author\\":[]}"]]},"headers":[{"level":3,"title":"def set_channel(name: str, channel: Channel) -> None","slug":"def-set-channel-name-str-channel-channel-none","link":"#def-set-channel-name-str-channel-channel-none","children":[]},{"level":3,"title":"def set_channels(channels: dict[str, Channel]) -> None","slug":"def-set-channels-channels-dict-str-channel-none","link":"#def-set-channels-channels-dict-str-channel-none","children":[]},{"level":3,"title":"def get_channel(name: str) -> Channel","slug":"def-get-channel-name-str-channel","link":"#def-get-channel-name-str-channel","children":[]},{"level":3,"title":"def get_channels() -> dict[str, Channel]","slug":"def-get-channels-dict-str-channel","link":"#def-get-channels-dict-str-channel","children":[]},{"level":3,"title":"def on_set_channel(data: tuple[str, dict[str, Any]]) -> None","slug":"def-on-set-channel-data-tuple-str-dict-str-any-none","link":"#def-on-set-channel-data-tuple-str-dict-str-any-none","children":[]},{"level":3,"title":"def on_get_channel(data: tuple[str, dict[str, Any]]) -> None","slug":"def-on-get-channel-data-tuple-str-dict-str-any-none","link":"#def-on-get-channel-data-tuple-str-dict-str-any-none","children":[]},{"level":3,"title":"def on_get_channels(data: tuple[str, dict[str, Any]]) -> None","slug":"def-on-get-channels-data-tuple-str-dict-str-any-none","link":"#def-on-get-channels-data-tuple-str-dict-str-any-none","children":[]},{"level":3,"title":"def decorator(func: Callable[[T], Any]) -> Callable[[T], Any]","slug":"def-decorator-func-callable-t-any-callable-t-any","link":"#def-decorator-func-callable-t-any-callable-t-any","children":[]},{"level":3,"title":"async def wrapper(data: T) -> Any","slug":"async-def-wrapper-data-t-any","link":"#async-def-wrapper-data-t-any","children":[]},{"level":3,"title":"class Channel(Generic[T])","slug":"class-channel-generic-t","link":"#class-channel-generic-t","children":[]},{"level":3,"title":"def __init__(self, _id: str, type_check: bool) -> None","slug":"def-init-self-id-str-type-check-bool-none","link":"#def-init-self-id-str-type-check-bool-none","children":[]},{"level":3,"title":"def send(self, data: T) -> None","slug":"def-send-self-data-t-none","link":"#def-send-self-data-t-none","children":[]},{"level":3,"title":"def receive(self) -> T","slug":"def-receive-self-t","link":"#def-receive-self-t","children":[]},{"level":3,"title":"def close(self) -> None","slug":"def-close-self-none","link":"#def-close-self-none","children":[]},{"level":3,"title":"def on_receive(self, filter_func: Optional[FILTER_FUNC]) -> Callable[[Callable[[T], Any]], Callable[[T], Any]]","slug":"def-on-receive-self-filter-func-optional-filter-func-callable-callable-t-any-callable-t-any","link":"#def-on-receive-self-filter-func-optional-filter-func-callable-callable-t-any-callable-t-any","children":[]},{"level":3,"title":"var T = TypeVar('T')","slug":"var-t-typevar-t","link":"#var-t-typevar-t","children":[]},{"level":3,"title":"var channel_deliver_active_channel = Channel(_id='channel_deliver_active_channel')","slug":"var-channel-deliver-active-channel-channel-id-channel-deliver-active-channel","link":"#var-channel-deliver-active-channel-channel-id-channel-deliver-active-channel","children":[]},{"level":3,"title":"var channel_deliver_passive_channel = Channel(_id='channel_deliver_passive_channel')","slug":"var-channel-deliver-passive-channel-channel-id-channel-deliver-passive-channel","link":"#var-channel-deliver-passive-channel-channel-id-channel-deliver-passive-channel","children":[]},{"level":3,"title":"var recv_chan = data[1]['recv_chan']","slug":"var-recv-chan-data-1-recv-chan","link":"#var-recv-chan-data-1-recv-chan","children":[]},{"level":3,"title":"var recv_chan = Channel[Channel[Any]]('recv_chan')","slug":"var-recv-chan-channel-channel-any-recv-chan","link":"#var-recv-chan-channel-channel-any-recv-chan","children":[]},{"level":3,"title":"var recv_chan = Channel[dict[str, Channel[Any]]]('recv_chan')","slug":"var-recv-chan-channel-dict-str-channel-any-recv-chan","link":"#var-recv-chan-channel-dict-str-channel-any-recv-chan","children":[]},{"level":3,"title":"var data = self.conn_recv.recv()","slug":"var-data-self-conn-recv-recv","link":"#var-data-self-conn-recv-recv","children":[]},{"level":3,"title":"var func = _callback_funcs[func_id]","slug":"var-func-callback-funcs-func-id","link":"#var-func-callback-funcs-func-id","children":[]},{"level":3,"title":"var func = _callback_funcs[func_id]","slug":"var-func-callback-funcs-func-id-1","link":"#var-func-callback-funcs-func-id-1","children":[]},{"level":3,"title":"var data = self.conn_recv.recv()","slug":"var-data-self-conn-recv-recv-1","link":"#var-data-self-conn-recv-recv-1","children":[]},{"level":3,"title":"var data = self.conn_recv.recv()","slug":"var-data-self-conn-recv-recv-2","link":"#var-data-self-conn-recv-recv-2","children":[]}],"git":{"createdTime":1724031826000,"updatedTime":1724034144000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":4}]},"readingTime":{"minutes":1.23,"words":369},"filePathRelative":"dev/api/comm/channel.md","localizedDate":"2024年8月19日","autoDesc":true}`);export{i as comp,f as data};