forked from I2P_Developers/i2p.www
Added highlighting to get-involved/develop/applications
This commit is contained in:
@@ -302,7 +302,7 @@ and creating an I2PServerSocket.
|
|||||||
In addition, we will ask the I2PSocketManager for an I2PSession, so we can find out the Destination we use.
|
In addition, we will ask the I2PSocketManager for an I2PSession, so we can find out the Destination we use.
|
||||||
{%- endtrans %}</p>
|
{%- endtrans %}</p>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<pre>
|
{% highlight lang='java' %}
|
||||||
package i2p.echoserver;
|
package i2p.echoserver;
|
||||||
|
|
||||||
import net.i2p.client.I2PSession;
|
import net.i2p.client.I2PSession;
|
||||||
@@ -322,8 +322,7 @@ In addition, we will ask the I2PSocketManager for an I2PSession, so we can find
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</pre>
|
{% endhighlight %}
|
||||||
<br /><br />
|
|
||||||
<p style="text-align:center">{{ _('Code example 1: initializing the server application.') }}</p>
|
<p style="text-align:center">{{ _('Code example 1: initializing the server application.') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<p>{% trans -%}
|
<p>{% trans -%}
|
||||||
@@ -335,11 +334,10 @@ Once we have created the I2PSocket instance, we read data, print it and send it
|
|||||||
The bold code is the new code we add.
|
The bold code is the new code we add.
|
||||||
{%- endtrans %}</p>
|
{%- endtrans %}</p>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<pre>
|
{% highlight lang='java',
|
||||||
|
hl_lines=[3,4,5,6,7,8,9,10,25,26,27,28,29,32,34,35,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,65,67] %}
|
||||||
package i2p.echoserver;
|
package i2p.echoserver;
|
||||||
|
|
||||||
</pre>
|
|
||||||
<pre><b>
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@@ -348,8 +346,7 @@ The bold code is the new code we add.
|
|||||||
import net.i2p.I2PException;
|
import net.i2p.I2PException;
|
||||||
import net.i2p.client.streaming.I2PSocket;
|
import net.i2p.client.streaming.I2PSocket;
|
||||||
import net.i2p.util.I2PThread;
|
import net.i2p.util.I2PThread;
|
||||||
</b></pre>
|
|
||||||
<pre>
|
|
||||||
import net.i2p.client.I2PSession;
|
import net.i2p.client.I2PSession;
|
||||||
import net.i2p.client.streaming.I2PServerSocket;
|
import net.i2p.client.streaming.I2PServerSocket;
|
||||||
import net.i2p.client.streaming.I2PSocketManager;
|
import net.i2p.client.streaming.I2PSocketManager;
|
||||||
@@ -362,8 +359,6 @@ The bold code is the new code we add.
|
|||||||
I2PServerSocket serverSocket = manager.getServerSocket();
|
I2PServerSocket serverSocket = manager.getServerSocket();
|
||||||
I2PSession session = manager.getSession();
|
I2PSession session = manager.getSession();
|
||||||
System.out.println(session.getMyDestination().toBase64()); //Print the base64 string, the regular string would look like garbage.
|
System.out.println(session.getMyDestination().toBase64()); //Print the base64 string, the regular string would look like garbage.
|
||||||
</pre>
|
|
||||||
<pre><b>
|
|
||||||
|
|
||||||
//Create socket to handle clients
|
//Create socket to handle clients
|
||||||
I2PThread t = new I2PThread(new ClientHandler(serverSocket));
|
I2PThread t = new I2PThread(new ClientHandler(serverSocket));
|
||||||
@@ -410,8 +405,7 @@ The bold code is the new code we add.
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</b></pre>
|
{% endhighlight %}
|
||||||
<br /><br />
|
|
||||||
<p style="text-align:center">{{ _('Code example 2: accepting connections from clients and handling messages.') }}</p>
|
<p style="text-align:center">{{ _('Code example 2: accepting connections from clients and handling messages.') }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -443,7 +437,7 @@ We will ask the user for the Destination string, and create an I2PSocket using t
|
|||||||
Once we have an I2PSocket, we can start sending and receiving data to and from the server.
|
Once we have an I2PSocket, we can start sending and receiving data to and from the server.
|
||||||
{%- endtrans %}</p>
|
{%- endtrans %}</p>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<pre>
|
{% highlight lang='java' %}
|
||||||
package i2p.echoclient;
|
package i2p.echoclient;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -514,8 +508,7 @@ Once we have an I2PSocket, we can start sending and receiving data to and from t
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</pre>
|
{% endhighlight %}
|
||||||
<br /><br />
|
|
||||||
<p style="text-align:center">{{ _('Code example 3: starting the client and connecting it to the server application.') }}</p>
|
<p style="text-align:center">{{ _('Code example 3: starting the client and connecting it to the server application.') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<p>{% trans -%}
|
<p>{% trans -%}
|
||||||
|
Reference in New Issue
Block a user