1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META http-equiv="Content-Style-Type" content="text/css"> 6<TITLE>NWC24 Message API Introduction</TITLE> 7<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css"> 8<LINK rel="stylesheet" type="text/css" href="../nwc24.css"> 9</HEAD> 10<BODY> 11<H1>NWC24 Message API</H1> 12 13<H2>Introduction</H2> 14<P> 15The NWC24 message API provides an environment to create, view, and manage messages that are exchanged between Wii consoles or between a Wii console and an external e-mail environment. 16</P> 17 18<H2>Overview</H2> 19<DL> 20<DT>WiiConnect24 Message</DT> 21<DD> 22<P> 23WiiConnect24 messages can be exchanged between Wii consoles or between a Wii console and an external e-mail environment using standard e-mail technology. Specifically, messages exchanged between Wii consoles are called <STRONG>Wii Messages</STRONG> and messages exchanged between a Wii console and an external e-mail environment are called <STRONG>Public Messages</STRONG>. 24</P> 25<P> 26Just like a standard e-mail message, a WiiConnect24 message consists of information about the sender and recipient, a subject, and body text. It can also handle up to two binary data files as attachments. Each application can communicate by including messages to friends, images, game data, and other information in these messages. 27</P> 28<P> 29Although the internal format of a WiiConnect24 message conforms to the standard e-mail format, because the library performs all format processing, output can be simplified by using a format where only text strings and data are passed to a function (as seen from the perspective of the application). 30</P> 31</DD> 32 33<DT>Outbox/Inbox</DT> 34<DD> 35<P> 36The Outbox and Inbox are temporary storage locations for messages allocated from part of Wii console NAND memory. They are allocated in a special location that cannot be accessed using standard NAND functions. 37</P> 38<P> 39The Outbox is used to store WiiConnect24 messages created by an application. Messages located here are sent periodically by automatic send/receive firmware upon connection to the server. (With some exceptions, messages are deleted after they are sent.) 40</P> 41<P> 42The Outbox has a capacity of around 2 MB and can hold up to a maximum of 127 messages. 43</P> 44<P> 45The Outbox can become full in certain cases, such as when the automatic send/receive feature is stopped or when communications are interrupted. When this happens the Outbox will not accept any new messages. 46</P> 47<P> 48The Inbox is used to store messages received from the server via the automatic send/receive function. Each message is saved until the application opens and deletes it or until the Inbox becomes full. (If the Inbox becomes full, messages are deleted in the order of oldest message first.) 49</P> 50<P> 51The Inbox has a capacity of around 7 MB and can hold a maximum of 255 messages. 52</P> 53</DD> 54</DL> 55 56<H2>Using the NWC24 Message Function</H2> 57 58<H4>Initializing the NWC24 Message Library</H4> 59<P> 60The library must be open in order to use the NWC24 message function. Use <A href="../Misc/NWC24OpenLib.html"><CODE>NWC24OpenLib</CODE></A> to open the library. If the library is not completely open, an error will result when an attempt is made to execute some NWC24 functions. 61</P> 62<P> 63Use <A href="../Misc/NWC24CloseLib.html"><CODE>NWC24CloseLib</CODE></A> to close the library once the series of processing is complete. <B>Note:</B> Automatic send/receive processing will not launch if the library is not closed. 64</P> 65 66<H4>Procedure to Create WiiConnect24 Messages</H4> 67<P> 68The actual procedure used to create a WiiConnect24 message and store it in the Outbox is given below: 69</P> 70<OL> 71<LI>Allocate and initialize an NWC24MsgObj object (<A href="NWC24InitMsgObj.html"><CODE>NWC24InitMsgObj</CODE></A>) 72<LI>Set all information for the object (<CODE>NWC24SetMsg*</CODE> functions) 73<LI>Create a message and store it in the Outbox (<A href="NWC24CommitMsg.html"><CODE>NWC24CommitMsg</CODE></A>) 74</OL> 75<P> 76Set information such as the destination address and body text using an <A href="../Types/NWC24MsgObj.html"><CODE>NWC24MsgObj</CODE> object</A>. <CODE>NWC24MsgObj</CODE> holds pointers to individual data items temporarily. 77</P> 78<P> 79Once all required information has been registered, call the <A href="NWC24CommitMsg.html"><CODE>NWC24CommitMsg()</CODE> function</A> to create a message in e-mail format corresponding to the information set for this object and store it in the Outbox. 80</P> 81<P> 82Character strings such as the message body and subject are merely passed to the internal format as they are. The use of a dedicated function like <A HREF="NWC24SetMsgSubjectAndTextPublic.html"><CODE>NWC24SetMsgSubjectAndTextPublic()</CODE></A> to handle multiple language responses in public messages will automatically convert text encoding internally. (Internally, the ENC library included in the Revolution SDK is called.) 83</P> 84 85<H4>Procedure to Obtain a List of WiiConnect24 Messages</H4> 86<P> 87The procedure for getting a list of messages stored in the Outbox or Inbox is given below: 88</P> 89<OL> 90<LI>Get the list of message IDs maintained by the box in question 91<LI>Get management information for each ID retrieved (<A href="NWC24GetMsgObj.html"><CODE>NWC24GetMsgObj</CODE></A>) 92<LI>Extract each element from the management information retrieved (<CODE>NWC24GetMsg*</CODE> functions) 93</OL> 94<P> 95The WiiConnect24 messages stored in each box are assigned individual 32-bit message IDs. If you want to get a list of messages, first call the <CODE><A href="NWC24GetMsgIdList.html">NWC24GetMsgIdList()</A></CODE> function to get a list of IDs being maintained by the box. 96</P> 97<P> 98Next, specify one of the IDs in the ID list and call the <A href="NWC24GetMsgObj.html"><CODE>NWC24GetMsgObj()</CODE> function</A>, which gets the meta-information for the message specified and stores it in a <A href="../Types/NWC24MsgObj.html"><CODE>NWC24MsgObj</CODE> structure</A>. 99</P> 100<P> 101The meta-information obtained here includes information required for searching messages, such as the sender, date of creation, application ID, etc. Use separate functions to get that information to determine whether an application needs to handle the message. 102</P> 103<P> 104The <A href="../Search/intro.html">Message Search Utility Function</A> has been prepared as a method to more simply obtain the list of messages. 105</P> 106 107<H4>Procedure to Obtain WiiConnect24 Messages</H4> 108<P> 109The procedure for getting messages is simply an extension of the procedure described above for getting a list of messages. 110</P> 111<P> 112After retrieving the list of message IDs for the box in question, call the <A href="NWC24GetMsgObj.html"><CODE>NWC24GetMsgObj()</CODE> function</A> and store meta information for the message having the specified ID in an <A href="../Types/NWC24MsgObj.html"><CODE>NWC24MsgObj</CODE> object</A>. 113</P> 114<P> 115As described above, meta-information such as the sender ID, date, etc. can be retrieved at this point by using the <CODE>NWC24GetMsg*</CODE> functions without accessing actual message files. 116</P> 117<P> 118Get variable length parts of the message, such as body text and attached files, using the <CODE>NWC24ReadMsg*</CODE> functions based on the <A href="../Types/NWC24MsgObj.html">NWC24MsgObj object</A>, that includes the meta-information that was retrieved. These functions actually access message files internally and read the data. 119</P> 120 121<H4>Procedure to Delete WiiConnect24 Messages</H4> 122<P> 123Once the application has retrieved a message from the inbox and is done with it, the message must be deleted quickly in order to maintain storage capacity (unless there is some reason to keep the message). 124</P> 125<P> 126Use the <A href="NWC24DeleteMsg.html"><CODE>NWC24DeleteMsg() </CODE>function</A> to delete messages by simply specifying the box in question and the message ID. 127</P> 128<P> 129This function can be used to delete messages stored in the Outbox as well as those stored in the Inbox. 130</P> 131<P> 132However, as a rule, deletion can be performed only from the application that created the message. Also, messages handled by the Wii Menu's Wii Message Board is deleted automatically by the Wii Message Board. 133</P> 134 135<H2>Access Rights to WiiConnect24 Messages</H2> 136 137<H4>Application ID and Group ID</H4> 138<P> 139When a message is exchanged between Wii consoles, the Application ID and Group ID of the application sending the message is incorporated into the message automatically. 140</P> 141<P> 142The Application ID is 4 bytes of information, and the actual value specified for this information is the application's game code. The Group ID is 2 bytes of information, and the actual value specified for this information is the application's company code. You can get the ID information embedded in each message using <code><A href="NWC24GetMsgAppId.html">NWC24GetMsgAppId</A></code> and <code><A href="NWC24GetMsgGroupId.html">NWC24GetMsgGroupId</A></code>. 143</P> 144<P> 145When an application reads a received message, it checks whether the ID in the message matches its own ID and uses this to determine whether the message was sent by the same or a different application. If the only difference in the Application ID is the destination region (the fourth character of the game code), the application assumes the sender application is the same as itself. 146</P> 147<P> 148Given the above specifications, the same application can handle WiiConnect24 messages regardless of the destination region. Conversely, to handle only closed messages for a specific destination region, you must assign based on the application ID value for the received message. 149</P> 150 151<H4>Access Rights for Different Message Types</H4> 152<P> 153The Wii Menu includes a feature called the Wii Message Board for viewing WiiConnect24 messages received by the Wii console. This allows users to view messages from a particular application without starting (or owning) that application. For details on how to output messages onto the Wii Message Board, see <A HREF="../MsgBoard/intro.html">NWC24API and Wii Message Board</A>In such cases, be sure to specify <A href="../Types/NWC24MsgType.html"><CODE>NWC24_MSGTYPE_WII_MENU</CODE></A> or <A href="../Types/NWC24MsgType.html"><CODE>NWC24_MSGTYPE_WII_MENU_SHARED</CODE></A> as the message type when performing initialization with <A href="NWC24InitMsgObj.html"><CODE>NWC24InitMsgObj()</CODE></A>. 154</P> 155<UL> 156<LI>Messages specifying <A href="../Types/NWC24MsgType.html"><CODE>NWC24_MSGTYPE_WII_MENU</CODE></A> cannot be accessed from a standard application.</LI> 157<LI>If <CODE>NWC24_MSGTYPE_WII_MENU_SHARED</CODE> is specified, the message is read-only.</LI> 158<LI><A href="../Types/NWC24MsgType.html">NWC24_MSGTYPE_PUBLIC</A> is for messages that come from external e-mail addresses. These messages are also processed by the Wii Message Board, and applications can only read these messages.</LI> 159</UL> 160<P> 161To exchange data between applications, create a "for application" message. In such cases, be sure to specify <A href="../Types/NWC24MsgType.html"><CODE>NWC24_MSGTYPE_WII_APP</CODE></A> as the message type when performing initialization with <A href="NWC24InitMsgObj.html"><CODE>NWC24InitMsgObj()</CODE></A>. In addition, when <A href="../Types/NWC24MsgType.html"><CODE>NWC24_MSGTYPE_WII_APP_HIDDEN</CODE></A> is specified, access from other applications is completely prohibited, allowing communication only within an application. 162</P> 163 164<H4>Keeping the content of messages secret</H4> 165<P> 166Although the WiiConnect24 mechanism maintains a certain level of communication security, no special measures have been taken regarding the possibility of data being read by other applications. 167</P> 168<P> 169If you want to implement stricter data security, specify <A href="../Types/NWC24MsgType.html"><CODE>NWC24_MSGTYPE_WII_APP_HIDDEN</CODE></A> and take additional measures, such as using the NET library to encrypt the data. 170</P> 171 172<H2>WiiConnect24 Message Size Restrictions</H2> 173<P> 174The maximum size of messages that can be created using the NWC24 API is 200 KB (more specifically, 203,776 bytes). The message body and any attachment data must fall within this size restriction. The header size is not included in this restriction. 175</P> 176<P> 177The use of attachments and body text that is MIME-encoded may result in sizes larger than the original data, which will mean that the actual size of usable data will be smaller than the restriction. (When encoded in Base64 format, the increase in data size over the original, for example, will be by a factor of 78/57. Thus, when the body is left blank, a maximum of roughly 140 KB of data can be attached. To calculate the size after Base64 encoding, use the macro <CODE>NWC24_BASE64_ENCODED_SIZE()</CODE>. 178</P> 179 180<H2>Certainty of Sending and Receiving WiiConnect24 Messages</H2> 181<P> 182WiiConnect24 messages are sent and received using standard e-mail technologies. In other words, there is no system to guarantee with 100% certainty that a sent message has reached the other party. 183</P> 184<P> 185Furthermore, the sending of the message may fail due to such factors as: 186</P> 187<UL> 188<LI>The server's message box is full. 189<LI>The Wii console's Inbox is full. 190</UL> 191<P> 192 These factors do not arise often with normal messaging, but you should make sure to design your applications to not fail when messages don't reach the other party. 193</P> 194<P> 195Note also that it is possible for messages to arrive significantly late, and when multiple messages are sent, for the order of reception to differ from the order of transmission. 196</P> 197 198<H2>Revision History</H2> 199<P> 2002007/11/27 Made revisions in conjunction with the present implementation. 201<BR> 2007/10/15 Added text relevant to the certainty of sending and receiving messages. <BR> 2007/04/04 Added a section about the maximum number of messages to store.<BR>2007/03/15 Added a section about access rights.<BR>2007/01/30 Minor revisions.<BR>2007/01/12 Added a section about size restrictions.<BR>2006/12/08 Separated section out from the overall introduction.</P> 202 203<hr><p>CONFIDENTIAL</p></body> 204</HTML>