Mojo API

Tentative — subject to change

Mojo provides two separate APIs that applications can call. The first one, which launches DAOC, is discussed elsewhere. The second one, which is described on this page, is at a very early stage of development.

This second API is called via a named pipe. Mojo is the server. The pipe's name is:

\\.\pipe\{250B6AEF-524A-4B4F-959B-A438D129B10C}

To use this API, open that pipe with CreateFile() or a .NET equivalent of CreateFile() and write XML messages to it. If Mojo is running, it will perform actions in DAOC and send XML messages back to you.

Requirements:

DoEditBox

At the present time, Mojo recognizes only two commands. The first one, called “DoEditBox”, makes Mojo open a modal dialog box in DAOC, accept one field of input from the user, and send the input back to you.

Here’s what you write to the pipe to make this happen:

<MojoApi>
  <ClientCall>
    <Name>DoEditBox</Name>
    <ReturnId>333</ReturnId>
    <Args>
      <Arg>Pastiche</Arg>
      <Arg>Pistachio</Arg>
    </Args>
  </ClientCall>
</MojoApi>

If Mojo is unable to parse the XML, it will send back an error message.

Omit whitespace; it’s used here because this example will be read only by humans.

Escape these two characters in the values of XML fields:

< replace with &lt;
& replace with &amp;

ReturnId is optional. It can be any string you want. It will be returned to you in Mojo's reponse.

Args is optional.

The first arg is the header in the dialog box that Mojo will display. It can be anything you like.

The second arg is the eyebrow (caption) over the text entry field that Mojo will display. It can be anything you like.

Mojo will return the same XML block to you with an additional RetVal section that contains the user's action and input.

LaunchDiscord

This command checks whether Discord is running and if it isn’t, launches it. There’s no harm in calling it when Discord is already open.

If Discord is running after the call, either because it was already running or Mojo launched it, the function returns Success.

Syntax (omit whitespace):

<MojoApi>
  <ClientCall>
    <Name>LaunchDiscord</Name>
    <ReturnId>1976</ReturnId>
  </ClientCall>
</MojoApi>

If successful, the return value will contain the status “Success” and may also include a remark as shown in this example:

<RetVal>
  <Status>Success</Status>
  <Remark>Already running</Remark>
</RetVal>

If unsuccessful, the RetVal will contain the status “Failed” and may also include two other fields as shown in this example:

<RetVal>
  <Status>Failed</Status>
  <Remark>Unable to launch</Remark>
  <ShellExecuteRetVal>The specified path was not found.</ShellExecuteRetVal>
</RetVal>

This page was first published on February 20, 2018 and last modified on February 23, 2018