Mts Ipc Modules¶
mts_ipc.client Module¶
mts_ipc.server Module¶
- mts_ipc.server.route(name: Optional[str] = None)[source]¶
Used to register a coroutine as an endpoint when you don’t have access to an instance of
Server- Parameters
name (str) – The endpoint name. If not provided the method name will be used.
This can be used in cogs. For ex -
import mts_ipc as ipc from discord.ext import commands class IpcCog(commands.Cog): def __init__(self, bot): self.bot = bot @ipc.server.route(name = "test") async def test(self, data: ipc.server.IpcServerResponse): return "Successfully tested the endpoint, which name is " + str(data.endpoint)
- class mts_ipc.server.IpcServerResponse(data: dict)[source]¶
Server response made for handling coroutines reserved for endpoints.
- Parameters
data (dict) – The data from which response is to be made.
- class mts_ipc.server.Server(bot: Union[discord.client.Client, discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot], secret_key: str = 'public-ipc-key')[source]¶
The IPC server. Usually used on the bot process for receiving requests from the client.
- Parameters
bot (Union[
Client,Bot,AutoShardedBot]) – Your bot instancesecret_key (str) – A secret key. Used for authentication and should be the same as your client’s secret key.
- route(name: Optional[str] = None)[source]¶
Used to register a coroutine as an endpoint when you have access to an instance of
Server.- Parameters
name (str) – The endpoint name. If not provided the method name will be used.
- coroutine handle_accept(request: aiohttp.web_request.Request)[source]¶
Handles client requests from the client process.
- Parameters
request (
Request) – The request made by the client, parsed by aiohttp.
- start(*args, **kwargs) Tuple[aiohttp.web_app.Application, aiohttp.web_runner.TCPSite][source]¶
Method to start IPC
- Parameters
app (Optional[
Application]) – An aiohttp application if already made with important things. It is optional creates a new one when None given.path (Optional[str]) – The path where IPC connections are to be made, takes “/ipc” when None given.
host (Optional[str]) – The host where the app has to be host for ex ‘0.0.0.0’ for repl, defaults to localhost.
port (Optional[int]) – The port where app has to be run, defaults to 8080
- Returns
- Return type
Tuple[
Application,TCPSite]
- setup(app: Optional[aiohttp.web_app.Application] = None, path: Optional[str] = '/ipc') aiohttp.web_app.Application[source]¶
Setups IPC app but doesn’t runs it
- Parameters
app (Optional[
Application]) – An aiohttp application if already made with important things. It is optional creates a new one when None given.path (Optional[str]) – The path where IPC connections are to be made, takes “/ipc” when None given.
- Returns
formatted application
- Return type
application