Marauroa Chat Tutorial: Difference between revisions
Content deleted Content added
imported>Terin |
imported>Kymara add syntax highlighting. it is teh awesome |
||
Line 10:
We will start with the following implementation of the RPWorld
<source lang="java">
import marauroa.server.game.rp.RPWorld;
import marauroa.server.game.rp.MarauroaRPZone;
Line 30:
}
}
</
Don't forget to always implement the static get method which is used by Marauroa framework to retrieve an instance of your class.
Line 39:
<!-- Updated due to refactoring database access in Marauroa. -->
<!-- Please, see details here http://stendhal.game-host.org/wiki/index.php/Refactoring_Database_Access_in_Marauroa. -->
<source lang="java">
import java.util.List;
import java.sql.SQLException;
Line 158:
}
}
</
We again implement the static get() method which is used by Marauroa to retrieve the RuleProcessor instance.
Line 202:
=== Code ===
In order to create a client using Marauroa frameword you should extend the marauroa.client.ClientFramework class with your logic. Here is the source code for the chat client
<source lang="java">
import java.util.Map;
import java.util.List;
Line 342:
}
}
</
This is mostly a boilerplate code. We claim that we are "Chat" client, version "0.5" As you remember, our server will accept any "Chat" client, without version restrictions.
Line 355:
Marauroa frameword provides the main method for server, so that you don't need to care about execution loop. It is not true for server, so we will also need to implement the main module of our client. Here is a very easy solution
<source lang="java">
import java.io.IOException;
import java.lang.Thread;
Line 401:
}
}
</
Our main method does a couple of things. First of all, we create a new account if three command-line arguments are provided (login, password, email). Otherwise we just login with login and password specified.
Line 437:
=== Code ===
The design of our Client class allows us to easily use it in something more complex then Test class above. Here is the example of a simple Swing application that uses Client as a communication tool
<source lang="java">
import javax.swing.*;
import java.awt.event.*;
Line 552:
}
}
</
To create the layout of the elements NetBeans was used, but we concentrate just on the source code here.
Line 561:
The only thing left for the Swing client now is a main method. Here is the source code
<source lang="java">
final class Chat {
private Chat() {}
Line 569:
}
}
</
=== Deployment ===
You still use the same command for compilation
| |||